Loading core/java/android/app/ActivityManager.java +14 −12 Original line number Diff line number Diff line Loading @@ -561,8 +561,11 @@ public class ActivityManager { /** ID of stack that always on top (always visible) when it exist. */ public static final int PINNED_STACK_ID = DOCKED_STACK_ID + 1; /** Recents activity stack ID. */ public static final int RECENTS_STACK_ID = PINNED_STACK_ID + 1; /** Last static stack stack ID. */ public static final int LAST_STATIC_STACK_ID = PINNED_STACK_ID; public static final int LAST_STATIC_STACK_ID = RECENTS_STACK_ID; /** Start of ID range used by stacks that are created dynamically. */ public static final int FIRST_DYNAMIC_STACK_ID = LAST_STATIC_STACK_ID + 1; Loading Loading @@ -734,6 +737,13 @@ public class ActivityManager { || stackId == FREEFORM_WORKSPACE_STACK_ID || stackId == DOCKED_STACK_ID; } /** * Returns true if the input {@param stackId} is HOME_STACK_ID or RECENTS_STACK_ID */ public static boolean isHomeOrRecentsStack(int stackId) { return stackId == HOME_STACK_ID || stackId == RECENTS_STACK_ID; } /** * Returns true if activities contained in this stack can request visible behind by * calling {@link Activity#requestVisibleBehind}. Loading @@ -760,7 +770,8 @@ public class ActivityManager { /** Returns true if the input stack and its content can affect the device orientation. */ public static boolean canSpecifyOrientation(int stackId) { return stackId == HOME_STACK_ID || stackId == FULLSCREEN_WORKSPACE_STACK_ID; return stackId == HOME_STACK_ID || stackId == RECENTS_STACK_ID || stackId == FULLSCREEN_WORKSPACE_STACK_ID; } } Loading Loading @@ -1509,7 +1520,7 @@ public class ActivityManager { * Ignores all tasks that are on the home stack. * @hide */ public static final int RECENT_IGNORE_HOME_STACK_TASKS = 0x0008; public static final int RECENT_IGNORE_HOME_AND_RECENTS_STACK_TASKS = 0x0008; /** * Ignores the top task in the docked stack. Loading Loading @@ -2052,15 +2063,6 @@ public class ActivityManager { } } /** @hide */ public boolean isInHomeStack(int taskId) { try { return getService().isInHomeStack(taskId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Flag for {@link #moveTaskToFront(int, int)}: also move the "home" * activity along with the task, so it is positioned immediately behind Loading core/java/android/app/IActivityManager.aidl +0 −1 Original line number Diff line number Diff line Loading @@ -370,7 +370,6 @@ interface IActivityManager { // Start of L transactions String getTagForIntentSender(in IIntentSender sender, in String prefix); boolean startUserInBackground(int userid); boolean isInHomeStack(int taskId); void startLockTaskModeById(int taskId); void startLockTaskModeByToken(in IBinder token); void stopLockTaskMode(); Loading packages/SystemUI/src/com/android/systemui/recents/Recents.java +3 −3 Original line number Diff line number Diff line Loading @@ -438,9 +438,9 @@ public class Recents extends SystemUI SystemServicesProxy ssp = Recents.getSystemServices(); ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask(); boolean screenPinningActive = ssp.isScreenPinningActive(); boolean isRunningTaskInHomeStack = runningTask != null && SystemServicesProxy.isHomeStack(runningTask.stackId); if (runningTask != null && !isRunningTaskInHomeStack && !screenPinningActive) { boolean isRunningTaskInHomeOrRecentsStack = runningTask != null && ActivityManager.StackId.isHomeOrRecentsStack(runningTask.stackId); if (runningTask != null && !isRunningTaskInHomeOrRecentsStack && !screenPinningActive) { logDockAttempt(mContext, runningTask.topActivity, runningTask.resizeMode); if (runningTask.isDockable) { if (metricsDockAction != -1) { Loading packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +4 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.systemui.recents; import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; import static android.app.ActivityManager.StackId.RECENTS_STACK_ID; import static android.app.ActivityManager.StackId.isHomeOrRecentsStack; import static android.view.View.MeasureSpec; import android.app.ActivityManager; Loading Loading @@ -460,8 +462,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener // Return early if there is no running task (can't determine affiliated tasks in this case) ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask(); if (runningTask == null) return; // Return early if the running task is in the home stack (optimization) if (SystemServicesProxy.isHomeStack(runningTask.stackId)) return; // Return early if the running task is in the home/recents stack (optimization) if (isHomeOrRecentsStack(runningTask.stackId)) return; // Find the task in the recents list ArrayList<Task> tasks = focusedStack.getStackTasks(); Loading packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +23 −10 Original line number Diff line number Diff line Loading @@ -321,7 +321,7 @@ public class SystemServicesProxy { // Remove home/recents/excluded tasks int minNumTasksToQuery = 10; int numTasksToQuery = Math.max(minNumTasksToQuery, numLatestTasks); int flags = ActivityManager.RECENT_IGNORE_HOME_STACK_TASKS | int flags = ActivityManager.RECENT_IGNORE_HOME_AND_RECENTS_STACK_TASKS | ActivityManager.RECENT_INGORE_DOCKED_STACK_TOP_TASK | ActivityManager.RECENT_INGORE_PINNED_STACK_TASKS | ActivityManager.RECENT_IGNORE_UNAVAILABLE | Loading Loading @@ -399,21 +399,23 @@ public class SystemServicesProxy { if (mIam == null) return false; try { ActivityManager.StackInfo stackInfo = mIam.getStackInfo( ActivityManager.StackInfo homeStackInfo = mIam.getStackInfo( ActivityManager.StackId.HOME_STACK_ID); ActivityManager.StackInfo fullscreenStackInfo = mIam.getStackInfo( ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID); ComponentName topActivity = stackInfo.topActivity; boolean homeStackVisibleNotOccluded = stackInfo.visible; if (fullscreenStackInfo != null) { boolean isFullscreenStackOccludingHome = fullscreenStackInfo.visible && fullscreenStackInfo.position > stackInfo.position; homeStackVisibleNotOccluded &= !isFullscreenStackOccludingHome; } ActivityManager.StackInfo recentsStackInfo = mIam.getStackInfo( ActivityManager.StackId.RECENTS_STACK_ID); boolean homeStackVisibleNotOccluded = isStackNotOccluded(homeStackInfo, fullscreenStackInfo); boolean recentsStackVisibleNotOccluded = isStackNotOccluded(recentsStackInfo, fullscreenStackInfo); if (isHomeStackVisible != null) { isHomeStackVisible.value = homeStackVisibleNotOccluded; } return (homeStackVisibleNotOccluded && topActivity != null ComponentName topActivity = recentsStackInfo != null ? recentsStackInfo.topActivity : null; return (recentsStackVisibleNotOccluded && topActivity != null && topActivity.getPackageName().equals(RecentsImpl.RECENTS_PACKAGE) && Recents.RECENTS_ACTIVITIES.contains(topActivity.getClassName())); } catch (RemoteException e) { Loading @@ -422,6 +424,17 @@ public class SystemServicesProxy { return false; } private boolean isStackNotOccluded(ActivityManager.StackInfo stackInfo, ActivityManager.StackInfo fullscreenStackInfo) { boolean stackVisibleNotOccluded = stackInfo == null || stackInfo.visible; if (fullscreenStackInfo != null && stackInfo != null) { boolean isFullscreenStackOccludingg = fullscreenStackInfo.visible && fullscreenStackInfo.position > stackInfo.position; stackVisibleNotOccluded &= !isFullscreenStackOccludingg; } return stackVisibleNotOccluded; } /** * Returns whether this device has freeform workspaces. */ Loading Loading
core/java/android/app/ActivityManager.java +14 −12 Original line number Diff line number Diff line Loading @@ -561,8 +561,11 @@ public class ActivityManager { /** ID of stack that always on top (always visible) when it exist. */ public static final int PINNED_STACK_ID = DOCKED_STACK_ID + 1; /** Recents activity stack ID. */ public static final int RECENTS_STACK_ID = PINNED_STACK_ID + 1; /** Last static stack stack ID. */ public static final int LAST_STATIC_STACK_ID = PINNED_STACK_ID; public static final int LAST_STATIC_STACK_ID = RECENTS_STACK_ID; /** Start of ID range used by stacks that are created dynamically. */ public static final int FIRST_DYNAMIC_STACK_ID = LAST_STATIC_STACK_ID + 1; Loading Loading @@ -734,6 +737,13 @@ public class ActivityManager { || stackId == FREEFORM_WORKSPACE_STACK_ID || stackId == DOCKED_STACK_ID; } /** * Returns true if the input {@param stackId} is HOME_STACK_ID or RECENTS_STACK_ID */ public static boolean isHomeOrRecentsStack(int stackId) { return stackId == HOME_STACK_ID || stackId == RECENTS_STACK_ID; } /** * Returns true if activities contained in this stack can request visible behind by * calling {@link Activity#requestVisibleBehind}. Loading @@ -760,7 +770,8 @@ public class ActivityManager { /** Returns true if the input stack and its content can affect the device orientation. */ public static boolean canSpecifyOrientation(int stackId) { return stackId == HOME_STACK_ID || stackId == FULLSCREEN_WORKSPACE_STACK_ID; return stackId == HOME_STACK_ID || stackId == RECENTS_STACK_ID || stackId == FULLSCREEN_WORKSPACE_STACK_ID; } } Loading Loading @@ -1509,7 +1520,7 @@ public class ActivityManager { * Ignores all tasks that are on the home stack. * @hide */ public static final int RECENT_IGNORE_HOME_STACK_TASKS = 0x0008; public static final int RECENT_IGNORE_HOME_AND_RECENTS_STACK_TASKS = 0x0008; /** * Ignores the top task in the docked stack. Loading Loading @@ -2052,15 +2063,6 @@ public class ActivityManager { } } /** @hide */ public boolean isInHomeStack(int taskId) { try { return getService().isInHomeStack(taskId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Flag for {@link #moveTaskToFront(int, int)}: also move the "home" * activity along with the task, so it is positioned immediately behind Loading
core/java/android/app/IActivityManager.aidl +0 −1 Original line number Diff line number Diff line Loading @@ -370,7 +370,6 @@ interface IActivityManager { // Start of L transactions String getTagForIntentSender(in IIntentSender sender, in String prefix); boolean startUserInBackground(int userid); boolean isInHomeStack(int taskId); void startLockTaskModeById(int taskId); void startLockTaskModeByToken(in IBinder token); void stopLockTaskMode(); Loading
packages/SystemUI/src/com/android/systemui/recents/Recents.java +3 −3 Original line number Diff line number Diff line Loading @@ -438,9 +438,9 @@ public class Recents extends SystemUI SystemServicesProxy ssp = Recents.getSystemServices(); ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask(); boolean screenPinningActive = ssp.isScreenPinningActive(); boolean isRunningTaskInHomeStack = runningTask != null && SystemServicesProxy.isHomeStack(runningTask.stackId); if (runningTask != null && !isRunningTaskInHomeStack && !screenPinningActive) { boolean isRunningTaskInHomeOrRecentsStack = runningTask != null && ActivityManager.StackId.isHomeOrRecentsStack(runningTask.stackId); if (runningTask != null && !isRunningTaskInHomeOrRecentsStack && !screenPinningActive) { logDockAttempt(mContext, runningTask.topActivity, runningTask.resizeMode); if (runningTask.isDockable) { if (metricsDockAction != -1) { Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +4 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.systemui.recents; import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; import static android.app.ActivityManager.StackId.RECENTS_STACK_ID; import static android.app.ActivityManager.StackId.isHomeOrRecentsStack; import static android.view.View.MeasureSpec; import android.app.ActivityManager; Loading Loading @@ -460,8 +462,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener // Return early if there is no running task (can't determine affiliated tasks in this case) ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask(); if (runningTask == null) return; // Return early if the running task is in the home stack (optimization) if (SystemServicesProxy.isHomeStack(runningTask.stackId)) return; // Return early if the running task is in the home/recents stack (optimization) if (isHomeOrRecentsStack(runningTask.stackId)) return; // Find the task in the recents list ArrayList<Task> tasks = focusedStack.getStackTasks(); Loading
packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +23 −10 Original line number Diff line number Diff line Loading @@ -321,7 +321,7 @@ public class SystemServicesProxy { // Remove home/recents/excluded tasks int minNumTasksToQuery = 10; int numTasksToQuery = Math.max(minNumTasksToQuery, numLatestTasks); int flags = ActivityManager.RECENT_IGNORE_HOME_STACK_TASKS | int flags = ActivityManager.RECENT_IGNORE_HOME_AND_RECENTS_STACK_TASKS | ActivityManager.RECENT_INGORE_DOCKED_STACK_TOP_TASK | ActivityManager.RECENT_INGORE_PINNED_STACK_TASKS | ActivityManager.RECENT_IGNORE_UNAVAILABLE | Loading Loading @@ -399,21 +399,23 @@ public class SystemServicesProxy { if (mIam == null) return false; try { ActivityManager.StackInfo stackInfo = mIam.getStackInfo( ActivityManager.StackInfo homeStackInfo = mIam.getStackInfo( ActivityManager.StackId.HOME_STACK_ID); ActivityManager.StackInfo fullscreenStackInfo = mIam.getStackInfo( ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID); ComponentName topActivity = stackInfo.topActivity; boolean homeStackVisibleNotOccluded = stackInfo.visible; if (fullscreenStackInfo != null) { boolean isFullscreenStackOccludingHome = fullscreenStackInfo.visible && fullscreenStackInfo.position > stackInfo.position; homeStackVisibleNotOccluded &= !isFullscreenStackOccludingHome; } ActivityManager.StackInfo recentsStackInfo = mIam.getStackInfo( ActivityManager.StackId.RECENTS_STACK_ID); boolean homeStackVisibleNotOccluded = isStackNotOccluded(homeStackInfo, fullscreenStackInfo); boolean recentsStackVisibleNotOccluded = isStackNotOccluded(recentsStackInfo, fullscreenStackInfo); if (isHomeStackVisible != null) { isHomeStackVisible.value = homeStackVisibleNotOccluded; } return (homeStackVisibleNotOccluded && topActivity != null ComponentName topActivity = recentsStackInfo != null ? recentsStackInfo.topActivity : null; return (recentsStackVisibleNotOccluded && topActivity != null && topActivity.getPackageName().equals(RecentsImpl.RECENTS_PACKAGE) && Recents.RECENTS_ACTIVITIES.contains(topActivity.getClassName())); } catch (RemoteException e) { Loading @@ -422,6 +424,17 @@ public class SystemServicesProxy { return false; } private boolean isStackNotOccluded(ActivityManager.StackInfo stackInfo, ActivityManager.StackInfo fullscreenStackInfo) { boolean stackVisibleNotOccluded = stackInfo == null || stackInfo.visible; if (fullscreenStackInfo != null && stackInfo != null) { boolean isFullscreenStackOccludingg = fullscreenStackInfo.visible && fullscreenStackInfo.position > stackInfo.position; stackVisibleNotOccluded &= !isFullscreenStackOccludingg; } return stackVisibleNotOccluded; } /** * Returns whether this device has freeform workspaces. */ Loading