diff options
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java | 55 |
1 files changed, 12 insertions, 43 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java index 10618e0..2ddab48 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java +++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java @@ -86,8 +86,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta final static int sMinToggleDelay = 350; final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS"; - final static String sRecentsPackage = "com.android.systemui"; - final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity"; + public final static String sRecentsPackage = "com.android.systemui"; + public final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity"; /** * An implementation of ITaskStackListener, that allows us to listen for changes to the system @@ -111,10 +111,11 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta public void run() { RecentsConfiguration config = RecentsConfiguration.getInstance(); if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) { - ActivityManager.RunningTaskInfo runningTaskInfo = getTopMostTask(); + RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); + SystemServicesProxy ssp = loader.getSystemServicesProxy(); + ActivityManager.RunningTaskInfo runningTaskInfo = ssp.getTopMostTask(); // Load the next task only if we aren't svelte - RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext); loader.preloadTasks(plan, true /* isTopTaskHome */); RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options(); @@ -272,8 +273,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta } void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { if (mBootCompleted) { - ActivityManager.RunningTaskInfo topTask = getTopMostTask(); - if (topTask != null && isRecentsTopMost(topTask, null)) { + ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask(); + if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, null)) { // Notify recents to hide itself Intent intent = createLocalBroadcastIntent(mContext, ACTION_HIDE_RECENTS_ACTIVITY); intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, triggeredFromAltTab); @@ -336,7 +337,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta // Return early if there are no tasks if (stack.getTaskCount() == 0) return; - ActivityManager.RunningTaskInfo runningTask = getTopMostTask(); + ActivityManager.RunningTaskInfo runningTask = mSystemServicesProxy.getTopMostTask(); // Return early if there is no running task (can't determine affiliated tasks in this case) if (runningTask == null) return; // Return early if the running task is in the home stack (optimization) @@ -480,38 +481,6 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta } } - /** Gets the top task. */ - ActivityManager.RunningTaskInfo getTopMostTask() { - SystemServicesProxy ssp = mSystemServicesProxy; - List<ActivityManager.RunningTaskInfo> tasks = ssp.getRunningTasks(1); - if (!tasks.isEmpty()) { - return tasks.get(0); - } - return null; - } - - /** Returns whether the recents is currently running */ - boolean isRecentsTopMost(ActivityManager.RunningTaskInfo topTask, AtomicBoolean isHomeTopMost) { - SystemServicesProxy ssp = mSystemServicesProxy; - if (topTask != null) { - ComponentName topActivity = topTask.topActivity; - - // Check if the front most activity is recents - if (topActivity.getPackageName().equals(sRecentsPackage) && - topActivity.getClassName().equals(sRecentsActivity)) { - if (isHomeTopMost != null) { - isHomeTopMost.set(false); - } - return true; - } - - if (isHomeTopMost != null) { - isHomeTopMost.set(ssp.isInHomeStack(topTask.id)); - } - } - return false; - } - /** Toggles the recents activity */ void toggleRecentsActivity() { // If the user has toggled it too quickly, then just eat up the event here (it's better than @@ -523,9 +492,9 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta // If Recents is the front most activity, then we should just communicate with it directly // to launch the first task or dismiss itself - ActivityManager.RunningTaskInfo topTask = getTopMostTask(); + ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask(); AtomicBoolean isTopTaskHome = new AtomicBoolean(true); - if (topTask != null && isRecentsTopMost(topTask, isTopTaskHome)) { + if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) { // Notify recents to toggle itself Intent intent = createLocalBroadcastIntent(mContext, ACTION_TOGGLE_RECENTS_ACTIVITY); mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT); @@ -540,9 +509,9 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta /** Starts the recents activity if it is not already running */ void startRecentsActivity() { // Check if the top task is in the home stack, and start the recents activity - ActivityManager.RunningTaskInfo topTask = getTopMostTask(); + ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask(); AtomicBoolean isTopTaskHome = new AtomicBoolean(true); - if (topTask == null || !isRecentsTopMost(topTask, isTopTaskHome)) { + if (topTask == null || !mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) { startRecentsActivity(topTask, isTopTaskHome.get()); } } |