diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java index 37b4dcabb8..b08a46f3c2 100644 --- a/quickstep/src/com/android/quickstep/RecentTasksList.java +++ b/quickstep/src/com/android/quickstep/RecentTasksList.java @@ -75,7 +75,7 @@ public class RecentTasksList { private ArrayList mRunningTasks; public RecentTasksList(LooperExecutor mainThreadExecutor, KeyguardManager keyguardManager, - SystemUiProxy sysUiProxy) { + SystemUiProxy sysUiProxy, TopTaskTracker topTaskTracker) { mMainThreadExecutor = mainThreadExecutor; mKeyguardManager = keyguardManager; mChangeId = 1; @@ -106,6 +106,13 @@ public class RecentTasksList { RecentTasksList.this.onRunningTaskChanged(taskInfo); }); } + + @Override + public void onTaskMovedToFront(ActivityManager.RunningTaskInfo taskInfo) { + mMainThreadExecutor.execute(() -> { + topTaskTracker.onTaskMovedToFront(taskInfo); + }); + } }); // We may receive onRunningTaskAppeared events later for tasks which have already been // included in the list returned by mSysUiProxy.getRunningTasks(), or may receive @@ -135,7 +142,7 @@ public class RecentTasksList { * Asynchronously fetches the list of recent tasks, reusing cached list if available. * * @param loadKeysOnly Whether to load other associated task data, or just the key - * @param callback The callback to receive the list of recent tasks + * @param callback The callback to receive the list of recent tasks * @return The change id of the current task list */ public synchronized int getTasks(boolean loadKeysOnly, @@ -200,7 +207,7 @@ public class RecentTasksList { mChangeId++; } - /** + /** * Registers a listener for running tasks */ public void registerRunningTasksListener(RecentsModel.RunningTasksListener listener) { diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java index 98c1eb409c..6eefe4aee5 100644 --- a/quickstep/src/com/android/quickstep/RecentsModel.java +++ b/quickstep/src/com/android/quickstep/RecentsModel.java @@ -90,7 +90,8 @@ public class RecentsModel implements RecentTasksDataSource, IconChangeListener, this(context, new RecentTasksList(MAIN_EXECUTOR, context.getSystemService(KeyguardManager.class), - SystemUiProxy.INSTANCE.get(context)), + SystemUiProxy.INSTANCE.get(context), + TopTaskTracker.INSTANCE.get(context)), new TaskIconCache(context, RECENTS_MODEL_EXECUTOR, iconProvider), new TaskThumbnailCache(context, RECENTS_MODEL_EXECUTOR), iconProvider, diff --git a/quickstep/src/com/android/quickstep/TopTaskTracker.java b/quickstep/src/com/android/quickstep/TopTaskTracker.java index 29c80fd066..61ba56477d 100644 --- a/quickstep/src/com/android/quickstep/TopTaskTracker.java +++ b/quickstep/src/com/android/quickstep/TopTaskTracker.java @@ -64,7 +64,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskStackChangeListener, SafeCloseable { private static final String TAG = "TopTaskTracker"; - + private static final boolean DEBUG = true; public static MainThreadInitializedObject INSTANCE = @@ -204,7 +204,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub /** * @return index 0 will be task in left/top position, index 1 in right/bottom position. - * Will return empty array if device is not in staged split + * Will return empty array if device is not in staged split */ public int[] getRunningSplitTaskIds() { if (mMainStagePosition.taskId == INVALID_TASK_ID @@ -337,7 +337,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub */ public Task[] getPlaceholderTasks() { return mTopTask == null ? new Task[0] - : new Task[] {Task.from(new TaskKey(mTopTask), mTopTask, false)}; + : new Task[]{Task.from(new TaskKey(mTopTask), mTopTask, false)}; } /** diff --git a/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java b/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java index ed5526f410..03244eb0bf 100644 --- a/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java +++ b/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java @@ -48,6 +48,8 @@ public class RecentTasksListTest { @Mock private SystemUiProxy mockSystemUiProxy; + @Mock + private TopTaskTracker mTopTaskTracker; // Class under test private RecentTasksList mRecentTasksList; @@ -58,7 +60,7 @@ public class RecentTasksListTest { LooperExecutor mockMainThreadExecutor = mock(LooperExecutor.class); KeyguardManager mockKeyguardManager = mock(KeyguardManager.class); mRecentTasksList = new RecentTasksList(mockMainThreadExecutor, mockKeyguardManager, - mockSystemUiProxy); + mockSystemUiProxy, mTopTaskTracker); } @Test