Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae1ff4f8 authored by Matthew Ng's avatar Matthew Ng
Browse files

Split home stack into home and recents stack

Refactored functionality of home stack (HOME_STACK_ID) in the code
base to home stack and recents stack (RECENTS_STACK_ID). Also changed
function and variable names from homeStack to homeOrRecentsStack.

Differentiating home and recents stack will allow readablilty and
managing logic between home and recents stacks. For example, for
multi-window minimized dock state, the home and recents stacks can
be set to different rects where the home stack needs to be a fixed
large size while the recents stack is hidden and the dock stack is
animating to be minimized.

Fixes: 32839371
Test: ./run-test android.server.cts and manually tested split and
rotation
Change-Id: I7603359c2dc20e35924664178634eb761e0367a6
parent d4f9d374
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -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;
@@ -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}.
@@ -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;
        }
    }

@@ -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.
@@ -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
+0 −1
Original line number Diff line number Diff line
@@ -368,7 +368,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();
+3 −3
Original line number Diff line number Diff line
@@ -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) {
+4 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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();
+23 −10
Original line number Diff line number Diff line
@@ -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 |
@@ -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) {
@@ -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