Loading packages/SystemUI/src/com/android/systemui/recents/Constants.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -65,7 +65,8 @@ public class Constants { } } public static class TaskStackView { public static class TaskStackView { public static final int TaskStackOverscrollRange = 150; public static final int TaskStackMinOverscrollRange = 32; public static final int TaskStackMaxOverscrollRange = 128; public static final int FilterStartDelay = 25; public static final int FilterStartDelay = 25; } } } } Loading packages/SystemUI/src/com/android/systemui/recents/Recents.java +16 −46 Original line number Original line Diff line number Diff line Loading @@ -88,9 +88,9 @@ public class Recents extends SystemUI final static int sMinToggleDelay = 350; final static int sMinToggleDelay = 350; final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS"; public final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS"; final static String sRecentsPackage = "com.android.systemui"; public final static String sRecentsPackage = "com.android.systemui"; final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity"; public final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity"; /** /** * An implementation of ITaskStackListener, that allows us to listen for changes to the system * An implementation of ITaskStackListener, that allows us to listen for changes to the system Loading @@ -114,10 +114,11 @@ public class Recents extends SystemUI public void run() { public void run() { RecentsConfiguration config = RecentsConfiguration.getInstance(); RecentsConfiguration config = RecentsConfiguration.getInstance(); if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) { 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 // Load the next task only if we aren't svelte RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext); RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext); loader.preloadTasks(plan, true /* isTopTaskHome */); loader.preloadTasks(plan, true /* isTopTaskHome */); RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options(); RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options(); Loading Loading @@ -300,8 +301,8 @@ public class Recents extends SystemUI void hideRecentsInternal(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { void hideRecentsInternal(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { if (mBootCompleted) { if (mBootCompleted) { ActivityManager.RunningTaskInfo topTask = getTopMostTask(); ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask(); if (topTask != null && isRecentsTopMost(topTask, null)) { if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, null)) { // Notify recents to hide itself // Notify recents to hide itself Intent intent = createLocalBroadcastIntent(mContext, ACTION_HIDE_RECENTS_ACTIVITY); Intent intent = createLocalBroadcastIntent(mContext, ACTION_HIDE_RECENTS_ACTIVITY); intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, triggeredFromAltTab); intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, triggeredFromAltTab); Loading Loading @@ -369,7 +370,7 @@ public class Recents extends SystemUI // Return early if there are no tasks // Return early if there are no tasks if (stack.getTaskCount() == 0) return; 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) // Return early if there is no running task (can't determine affiliated tasks in this case) if (runningTask == null) return; if (runningTask == null) return; // Return early if the running task is in the home stack (optimization) // Return early if the running task is in the home stack (optimization) Loading Loading @@ -515,38 +516,6 @@ public class Recents extends SystemUI } } } } /** 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 */ /** Toggles the recents activity */ void toggleRecentsActivity() { void toggleRecentsActivity() { // If the user has toggled it too quickly, then just eat up the event here (it's better than // If the user has toggled it too quickly, then just eat up the event here (it's better than Loading @@ -558,9 +527,9 @@ public class Recents extends SystemUI // If Recents is the front most activity, then we should just communicate with it directly // If Recents is the front most activity, then we should just communicate with it directly // to launch the first task or dismiss itself // to launch the first task or dismiss itself ActivityManager.RunningTaskInfo topTask = getTopMostTask(); ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask(); AtomicBoolean isTopTaskHome = new AtomicBoolean(true); AtomicBoolean isTopTaskHome = new AtomicBoolean(true); if (topTask != null && isRecentsTopMost(topTask, isTopTaskHome)) { if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) { // Notify recents to toggle itself // Notify recents to toggle itself Intent intent = createLocalBroadcastIntent(mContext, ACTION_TOGGLE_RECENTS_ACTIVITY); Intent intent = createLocalBroadcastIntent(mContext, ACTION_TOGGLE_RECENTS_ACTIVITY); mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT); mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT); Loading @@ -575,9 +544,9 @@ public class Recents extends SystemUI /** Starts the recents activity if it is not already running */ /** Starts the recents activity if it is not already running */ void startRecentsActivity() { void startRecentsActivity() { // Check if the top task is in the home stack, and start the recents activity // 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); AtomicBoolean isTopTaskHome = new AtomicBoolean(true); if (topTask == null || !isRecentsTopMost(topTask, isTopTaskHome)) { if (topTask == null || !mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) { startRecentsActivity(topTask, isTopTaskHome.get()); startRecentsActivity(topTask, isTopTaskHome.get()); } } } } Loading Loading @@ -677,12 +646,13 @@ public class Recents extends SystemUI /** Starts the recents activity */ /** Starts the recents activity */ void startRecentsActivity(ActivityManager.RunningTaskInfo topTask, boolean isTopTaskHome) { void startRecentsActivity(ActivityManager.RunningTaskInfo topTask, boolean isTopTaskHome) { RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); RecentsConfiguration.reinitialize(mContext, mSystemServicesProxy); if (sInstanceLoadPlan == null) { if (sInstanceLoadPlan == null) { // Create a new load plan if onPreloadRecents() was never triggered // Create a new load plan if onPreloadRecents() was never triggered RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); sInstanceLoadPlan = loader.createLoadPlan(mContext); sInstanceLoadPlan = loader.createLoadPlan(mContext); } } RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); loader.preloadTasks(sInstanceLoadPlan, isTopTaskHome); loader.preloadTasks(sInstanceLoadPlan, isTopTaskHome); TaskStack stack = sInstanceLoadPlan.getTaskStack(); TaskStack stack = sInstanceLoadPlan.getTaskStack(); Loading packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +16 −15 Original line number Original line Diff line number Diff line Loading @@ -65,7 +65,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView DebugOverlayView.DebugOverlayViewCallbacks { DebugOverlayView.DebugOverlayViewCallbacks { RecentsConfiguration mConfig; RecentsConfiguration mConfig; boolean mVisible; long mLastTabKeyEventTime; long mLastTabKeyEventTime; // Top level views // Top level views Loading Loading @@ -181,7 +180,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView }); }); /** Updates the set of recent tasks */ /** Updates the set of recent tasks */ void updateRecentsTasks(Intent launchIntent) { void updateRecentsTasks() { // If AlternateRecentsComponent has preloaded a load plan, then use that to prevent // If AlternateRecentsComponent has preloaded a load plan, then use that to prevent // reconstructing the task stack // reconstructing the task stack RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); Loading Loading @@ -315,7 +314,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView /** Dismisses recents if we are already visible and the intent is to toggle the recents view */ /** Dismisses recents if we are already visible and the intent is to toggle the recents view */ boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) { boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) { if (mVisible) { SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { // If we currently have filtered stacks, then unfilter those first // If we currently have filtered stacks, then unfilter those first if (checkFilteredStackState && if (checkFilteredStackState && mRecentsView.unfilterFilteredStacks()) return true; mRecentsView.unfilterFilteredStacks()) return true; Loading Loading @@ -349,7 +349,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView /** Dismisses Recents directly to Home if we currently aren't transitioning. */ /** Dismisses Recents directly to Home if we currently aren't transitioning. */ boolean dismissRecentsToHome(boolean animated) { boolean dismissRecentsToHome(boolean animated) { if (mVisible) { SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { // Return to Home // Return to Home dismissRecentsToHomeRaw(animated); dismissRecentsToHomeRaw(animated); return true; return true; Loading @@ -361,12 +362,11 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView @Override @Override public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.onCreate(savedInstanceState); // For the non-primary user, ensure that the SystemSericesProxy is initialized // For the non-primary user, ensure that the SystemServicesProxy and configuration is // initialized RecentsTaskLoader.initialize(this); RecentsTaskLoader.initialize(this); SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); // Initialize the loader and the configuration mConfig = RecentsConfiguration.reinitialize(this, ssp); mConfig = RecentsConfiguration.reinitialize(this, RecentsTaskLoader.getInstance().getSystemServicesProxy()); // Initialize the widget host (the host id is static and does not change) // Initialize the widget host (the host id is static and does not change) mAppWidgetHost = new RecentsAppWidgetHost(this, Constants.Values.App.AppWidgetHostId); mAppWidgetHost = new RecentsAppWidgetHost(this, Constants.Values.App.AppWidgetHostId); Loading Loading @@ -421,9 +421,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView super.onNewIntent(intent); super.onNewIntent(intent); setIntent(intent); setIntent(intent); // Reinitialize the configuration RecentsConfiguration.reinitialize(this, RecentsTaskLoader.getInstance().getSystemServicesProxy()); // Clear any debug rects // Clear any debug rects if (mDebugOverlay != null) { if (mDebugOverlay != null) { mDebugOverlay.clear(); mDebugOverlay.clear(); Loading @@ -433,7 +430,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView @Override @Override protected void onStart() { protected void onStart() { super.onStart(); super.onStart(); mVisible = true; RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); SystemServicesProxy ssp = loader.getSystemServicesProxy(); SystemServicesProxy ssp = loader.getSystemServicesProxy(); Recents.notifyVisibilityChanged(this, ssp, true); Recents.notifyVisibilityChanged(this, ssp, true); Loading @@ -449,13 +445,18 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView loader.registerReceivers(this, mRecentsView); loader.registerReceivers(this, mRecentsView); // Update the recent tasks // Update the recent tasks updateRecentsTasks(getIntent()); updateRecentsTasks(); // If this is a new instance from a configuration change, then we have to manually trigger // the enter animation state if (mConfig.launchedHasConfigurationChanged) { onEnterAnimationTriggered(); } } } @Override @Override protected void onStop() { protected void onStop() { super.onStop(); super.onStop(); mVisible = false; RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); SystemServicesProxy ssp = loader.getSystemServicesProxy(); SystemServicesProxy ssp = loader.getSystemServicesProxy(); Recents.notifyVisibilityChanged(this, ssp, false); Recents.notifyVisibilityChanged(this, ssp, false); Loading packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +34 −1 Original line number Original line Diff line number Diff line Loading @@ -60,12 +60,14 @@ import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager; import com.android.systemui.R; import com.android.systemui.R; import com.android.systemui.recents.Constants; import com.android.systemui.recents.Constants; import com.android.systemui.recents.Recents; import java.io.IOException; import java.io.IOException; import java.util.ArrayList; import java.util.ArrayList; import java.util.Iterator; import java.util.Iterator; import java.util.List; import java.util.List; import java.util.Random; import java.util.Random; import java.util.concurrent.atomic.AtomicBoolean; /** /** * Acts as a shim around the real system services that we need to access data from, and provides * Acts as a shim around the real system services that we need to access data from, and provides Loading Loading @@ -212,11 +214,42 @@ public class SystemServicesProxy { } } /** Returns a list of the running tasks */ /** Returns a list of the running tasks */ public List<ActivityManager.RunningTaskInfo> getRunningTasks(int numTasks) { private List<ActivityManager.RunningTaskInfo> getRunningTasks(int numTasks) { if (mAm == null) return null; if (mAm == null) return null; return mAm.getRunningTasks(numTasks); return mAm.getRunningTasks(numTasks); } } /** Returns the top task. */ public ActivityManager.RunningTaskInfo getTopMostTask() { List<ActivityManager.RunningTaskInfo> tasks = getRunningTasks(1); if (!tasks.isEmpty()) { return tasks.get(0); } return null; } /** Returns whether the recents is currently running */ public boolean isRecentsTopMost(ActivityManager.RunningTaskInfo topTask, AtomicBoolean isHomeTopMost) { if (topTask != null) { ComponentName topActivity = topTask.topActivity; // Check if the front most activity is recents if (topActivity.getPackageName().equals(Recents.sRecentsPackage) && topActivity.getClassName().equals(Recents.sRecentsActivity)) { if (isHomeTopMost != null) { isHomeTopMost.set(false); } return true; } if (isHomeTopMost != null) { isHomeTopMost.set(isInHomeStack(topTask.id)); } } return false; } /** Returns whether the specified task is in the home stack */ /** Returns whether the specified task is in the home stack */ public boolean isInHomeStack(int taskId) { public boolean isInHomeStack(int taskId) { if (mAm == null) return false; if (mAm == null) return false; Loading packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -252,6 +252,8 @@ public class TaskStack { if (group.getTaskCount() == 0) { if (group.getTaskCount() == 0) { removeGroup(group); removeGroup(group); } } // Update the lock-to-app state t.lockToThisTask = false; if (mCb != null) { if (mCb != null) { // Notify that a task has been removed // Notify that a task has been removed mCb.onStackTaskRemoved(this, t, null); mCb.onStackTaskRemoved(this, t, null); Loading Loading
packages/SystemUI/src/com/android/systemui/recents/Constants.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -65,7 +65,8 @@ public class Constants { } } public static class TaskStackView { public static class TaskStackView { public static final int TaskStackOverscrollRange = 150; public static final int TaskStackMinOverscrollRange = 32; public static final int TaskStackMaxOverscrollRange = 128; public static final int FilterStartDelay = 25; public static final int FilterStartDelay = 25; } } } } Loading
packages/SystemUI/src/com/android/systemui/recents/Recents.java +16 −46 Original line number Original line Diff line number Diff line Loading @@ -88,9 +88,9 @@ public class Recents extends SystemUI final static int sMinToggleDelay = 350; final static int sMinToggleDelay = 350; final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS"; public final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS"; final static String sRecentsPackage = "com.android.systemui"; public final static String sRecentsPackage = "com.android.systemui"; final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity"; public final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity"; /** /** * An implementation of ITaskStackListener, that allows us to listen for changes to the system * An implementation of ITaskStackListener, that allows us to listen for changes to the system Loading @@ -114,10 +114,11 @@ public class Recents extends SystemUI public void run() { public void run() { RecentsConfiguration config = RecentsConfiguration.getInstance(); RecentsConfiguration config = RecentsConfiguration.getInstance(); if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) { 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 // Load the next task only if we aren't svelte RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext); RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext); loader.preloadTasks(plan, true /* isTopTaskHome */); loader.preloadTasks(plan, true /* isTopTaskHome */); RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options(); RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options(); Loading Loading @@ -300,8 +301,8 @@ public class Recents extends SystemUI void hideRecentsInternal(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { void hideRecentsInternal(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { if (mBootCompleted) { if (mBootCompleted) { ActivityManager.RunningTaskInfo topTask = getTopMostTask(); ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask(); if (topTask != null && isRecentsTopMost(topTask, null)) { if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, null)) { // Notify recents to hide itself // Notify recents to hide itself Intent intent = createLocalBroadcastIntent(mContext, ACTION_HIDE_RECENTS_ACTIVITY); Intent intent = createLocalBroadcastIntent(mContext, ACTION_HIDE_RECENTS_ACTIVITY); intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, triggeredFromAltTab); intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, triggeredFromAltTab); Loading Loading @@ -369,7 +370,7 @@ public class Recents extends SystemUI // Return early if there are no tasks // Return early if there are no tasks if (stack.getTaskCount() == 0) return; 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) // Return early if there is no running task (can't determine affiliated tasks in this case) if (runningTask == null) return; if (runningTask == null) return; // Return early if the running task is in the home stack (optimization) // Return early if the running task is in the home stack (optimization) Loading Loading @@ -515,38 +516,6 @@ public class Recents extends SystemUI } } } } /** 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 */ /** Toggles the recents activity */ void toggleRecentsActivity() { void toggleRecentsActivity() { // If the user has toggled it too quickly, then just eat up the event here (it's better than // If the user has toggled it too quickly, then just eat up the event here (it's better than Loading @@ -558,9 +527,9 @@ public class Recents extends SystemUI // If Recents is the front most activity, then we should just communicate with it directly // If Recents is the front most activity, then we should just communicate with it directly // to launch the first task or dismiss itself // to launch the first task or dismiss itself ActivityManager.RunningTaskInfo topTask = getTopMostTask(); ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask(); AtomicBoolean isTopTaskHome = new AtomicBoolean(true); AtomicBoolean isTopTaskHome = new AtomicBoolean(true); if (topTask != null && isRecentsTopMost(topTask, isTopTaskHome)) { if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) { // Notify recents to toggle itself // Notify recents to toggle itself Intent intent = createLocalBroadcastIntent(mContext, ACTION_TOGGLE_RECENTS_ACTIVITY); Intent intent = createLocalBroadcastIntent(mContext, ACTION_TOGGLE_RECENTS_ACTIVITY); mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT); mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT); Loading @@ -575,9 +544,9 @@ public class Recents extends SystemUI /** Starts the recents activity if it is not already running */ /** Starts the recents activity if it is not already running */ void startRecentsActivity() { void startRecentsActivity() { // Check if the top task is in the home stack, and start the recents activity // 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); AtomicBoolean isTopTaskHome = new AtomicBoolean(true); if (topTask == null || !isRecentsTopMost(topTask, isTopTaskHome)) { if (topTask == null || !mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) { startRecentsActivity(topTask, isTopTaskHome.get()); startRecentsActivity(topTask, isTopTaskHome.get()); } } } } Loading Loading @@ -677,12 +646,13 @@ public class Recents extends SystemUI /** Starts the recents activity */ /** Starts the recents activity */ void startRecentsActivity(ActivityManager.RunningTaskInfo topTask, boolean isTopTaskHome) { void startRecentsActivity(ActivityManager.RunningTaskInfo topTask, boolean isTopTaskHome) { RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); RecentsConfiguration.reinitialize(mContext, mSystemServicesProxy); if (sInstanceLoadPlan == null) { if (sInstanceLoadPlan == null) { // Create a new load plan if onPreloadRecents() was never triggered // Create a new load plan if onPreloadRecents() was never triggered RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); sInstanceLoadPlan = loader.createLoadPlan(mContext); sInstanceLoadPlan = loader.createLoadPlan(mContext); } } RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); loader.preloadTasks(sInstanceLoadPlan, isTopTaskHome); loader.preloadTasks(sInstanceLoadPlan, isTopTaskHome); TaskStack stack = sInstanceLoadPlan.getTaskStack(); TaskStack stack = sInstanceLoadPlan.getTaskStack(); Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +16 −15 Original line number Original line Diff line number Diff line Loading @@ -65,7 +65,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView DebugOverlayView.DebugOverlayViewCallbacks { DebugOverlayView.DebugOverlayViewCallbacks { RecentsConfiguration mConfig; RecentsConfiguration mConfig; boolean mVisible; long mLastTabKeyEventTime; long mLastTabKeyEventTime; // Top level views // Top level views Loading Loading @@ -181,7 +180,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView }); }); /** Updates the set of recent tasks */ /** Updates the set of recent tasks */ void updateRecentsTasks(Intent launchIntent) { void updateRecentsTasks() { // If AlternateRecentsComponent has preloaded a load plan, then use that to prevent // If AlternateRecentsComponent has preloaded a load plan, then use that to prevent // reconstructing the task stack // reconstructing the task stack RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); Loading Loading @@ -315,7 +314,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView /** Dismisses recents if we are already visible and the intent is to toggle the recents view */ /** Dismisses recents if we are already visible and the intent is to toggle the recents view */ boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) { boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) { if (mVisible) { SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { // If we currently have filtered stacks, then unfilter those first // If we currently have filtered stacks, then unfilter those first if (checkFilteredStackState && if (checkFilteredStackState && mRecentsView.unfilterFilteredStacks()) return true; mRecentsView.unfilterFilteredStacks()) return true; Loading Loading @@ -349,7 +349,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView /** Dismisses Recents directly to Home if we currently aren't transitioning. */ /** Dismisses Recents directly to Home if we currently aren't transitioning. */ boolean dismissRecentsToHome(boolean animated) { boolean dismissRecentsToHome(boolean animated) { if (mVisible) { SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { // Return to Home // Return to Home dismissRecentsToHomeRaw(animated); dismissRecentsToHomeRaw(animated); return true; return true; Loading @@ -361,12 +362,11 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView @Override @Override public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.onCreate(savedInstanceState); // For the non-primary user, ensure that the SystemSericesProxy is initialized // For the non-primary user, ensure that the SystemServicesProxy and configuration is // initialized RecentsTaskLoader.initialize(this); RecentsTaskLoader.initialize(this); SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); // Initialize the loader and the configuration mConfig = RecentsConfiguration.reinitialize(this, ssp); mConfig = RecentsConfiguration.reinitialize(this, RecentsTaskLoader.getInstance().getSystemServicesProxy()); // Initialize the widget host (the host id is static and does not change) // Initialize the widget host (the host id is static and does not change) mAppWidgetHost = new RecentsAppWidgetHost(this, Constants.Values.App.AppWidgetHostId); mAppWidgetHost = new RecentsAppWidgetHost(this, Constants.Values.App.AppWidgetHostId); Loading Loading @@ -421,9 +421,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView super.onNewIntent(intent); super.onNewIntent(intent); setIntent(intent); setIntent(intent); // Reinitialize the configuration RecentsConfiguration.reinitialize(this, RecentsTaskLoader.getInstance().getSystemServicesProxy()); // Clear any debug rects // Clear any debug rects if (mDebugOverlay != null) { if (mDebugOverlay != null) { mDebugOverlay.clear(); mDebugOverlay.clear(); Loading @@ -433,7 +430,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView @Override @Override protected void onStart() { protected void onStart() { super.onStart(); super.onStart(); mVisible = true; RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); SystemServicesProxy ssp = loader.getSystemServicesProxy(); SystemServicesProxy ssp = loader.getSystemServicesProxy(); Recents.notifyVisibilityChanged(this, ssp, true); Recents.notifyVisibilityChanged(this, ssp, true); Loading @@ -449,13 +445,18 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView loader.registerReceivers(this, mRecentsView); loader.registerReceivers(this, mRecentsView); // Update the recent tasks // Update the recent tasks updateRecentsTasks(getIntent()); updateRecentsTasks(); // If this is a new instance from a configuration change, then we have to manually trigger // the enter animation state if (mConfig.launchedHasConfigurationChanged) { onEnterAnimationTriggered(); } } } @Override @Override protected void onStop() { protected void onStop() { super.onStop(); super.onStop(); mVisible = false; RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); SystemServicesProxy ssp = loader.getSystemServicesProxy(); SystemServicesProxy ssp = loader.getSystemServicesProxy(); Recents.notifyVisibilityChanged(this, ssp, false); Recents.notifyVisibilityChanged(this, ssp, false); Loading
packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +34 −1 Original line number Original line Diff line number Diff line Loading @@ -60,12 +60,14 @@ import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager; import com.android.systemui.R; import com.android.systemui.R; import com.android.systemui.recents.Constants; import com.android.systemui.recents.Constants; import com.android.systemui.recents.Recents; import java.io.IOException; import java.io.IOException; import java.util.ArrayList; import java.util.ArrayList; import java.util.Iterator; import java.util.Iterator; import java.util.List; import java.util.List; import java.util.Random; import java.util.Random; import java.util.concurrent.atomic.AtomicBoolean; /** /** * Acts as a shim around the real system services that we need to access data from, and provides * Acts as a shim around the real system services that we need to access data from, and provides Loading Loading @@ -212,11 +214,42 @@ public class SystemServicesProxy { } } /** Returns a list of the running tasks */ /** Returns a list of the running tasks */ public List<ActivityManager.RunningTaskInfo> getRunningTasks(int numTasks) { private List<ActivityManager.RunningTaskInfo> getRunningTasks(int numTasks) { if (mAm == null) return null; if (mAm == null) return null; return mAm.getRunningTasks(numTasks); return mAm.getRunningTasks(numTasks); } } /** Returns the top task. */ public ActivityManager.RunningTaskInfo getTopMostTask() { List<ActivityManager.RunningTaskInfo> tasks = getRunningTasks(1); if (!tasks.isEmpty()) { return tasks.get(0); } return null; } /** Returns whether the recents is currently running */ public boolean isRecentsTopMost(ActivityManager.RunningTaskInfo topTask, AtomicBoolean isHomeTopMost) { if (topTask != null) { ComponentName topActivity = topTask.topActivity; // Check if the front most activity is recents if (topActivity.getPackageName().equals(Recents.sRecentsPackage) && topActivity.getClassName().equals(Recents.sRecentsActivity)) { if (isHomeTopMost != null) { isHomeTopMost.set(false); } return true; } if (isHomeTopMost != null) { isHomeTopMost.set(isInHomeStack(topTask.id)); } } return false; } /** Returns whether the specified task is in the home stack */ /** Returns whether the specified task is in the home stack */ public boolean isInHomeStack(int taskId) { public boolean isInHomeStack(int taskId) { if (mAm == null) return false; if (mAm == null) return false; Loading
packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -252,6 +252,8 @@ public class TaskStack { if (group.getTaskCount() == 0) { if (group.getTaskCount() == 0) { removeGroup(group); removeGroup(group); } } // Update the lock-to-app state t.lockToThisTask = false; if (mCb != null) { if (mCb != null) { // Notify that a task has been removed // Notify that a task has been removed mCb.onStackTaskRemoved(this, t, null); mCb.onStackTaskRemoved(this, t, null); Loading