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

Commit 5510f6c1 authored by Winson's avatar Winson Committed by Winson Chung
Browse files

Passing stack id with RunningTaskInfo.

- This allows us to remove an extraneous system call when starting 
  overview, and also allows us to easily check for freeform windows.

Change-Id: I4449dad7bf870f528f671f6e7cb1f9b5f1bc9c1c
parent 0983e02b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1192,6 +1192,12 @@ public class ActivityManager {
         */
        public int id;

        /**
         * The stack that currently contains this task.
         * @hide
         */
        public int stackId;

        /**
         * The component launched as the first activity in the task.  This can
         * be considered the "application" of this task.
@@ -1241,6 +1247,7 @@ public class ActivityManager {

        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(id);
            dest.writeInt(stackId);
            ComponentName.writeToParcel(baseActivity, dest);
            ComponentName.writeToParcel(topActivity, dest);
            if (thumbnail != null) {
@@ -1257,6 +1264,7 @@ public class ActivityManager {

        public void readFromParcel(Parcel source) {
            id = source.readInt();
            stackId = source.readInt();
            baseActivity = ComponentName.readFromParcel(source);
            topActivity = ComponentName.readFromParcel(source);
            if (source.readInt() != 0) {
+1 −1
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
        // 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)
        if (ssp.isInHomeStack(runningTask.id)) return;
        if (SystemServicesProxy.isHomeStack(runningTask.stackId)) return;

        // Find the task in the recents list
        ArrayList<Task> tasks = focusedStack.getTasks();
+14 −10
Original line number Diff line number Diff line
@@ -247,8 +247,10 @@ public class SystemServicesProxy {
                return true;
            }

            // Note, this is only valid because we currently only allow the recents and home
            // activities in the home stack
            if (isHomeTopMost != null) {
                isHomeTopMost.value = isInHomeStack(topTask.id);
                isHomeTopMost.value = SystemServicesProxy.isHomeStack(topTask.stackId);
            }
        }
        return false;
@@ -313,16 +315,18 @@ public class SystemServicesProxy {
        }
    }

    /** Returns whether the specified task is in the home stack */
    public boolean isInHomeStack(int taskId) {
        if (mAm == null) return false;

        // If we are mocking, then just return false
        if (Constants.DebugFlags.App.EnableSystemServicesProxy) {
            return false;
    /**
     * Returns whether the given stack id is the home stack id.
     */
    public static boolean isHomeStack(int stackId) {
        return stackId == ActivityManager.HOME_STACK_ID;
    }

        return mAm.isInHomeStack(taskId);
    /**
     * Returns whether the given stack id is the freeform workspace stack id.
     */
    public static boolean isFreeformStack(int stackId) {
        return stackId == ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
    }

    /**
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.app.ActivityManager.FIRST_STATIC_STACK_ID;
import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.HOME_STACK_ID;
import static android.app.ActivityManager.INVALID_STACK_ID;
import static android.app.ActivityManager.LAST_STATIC_STACK_ID;
import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;

@@ -4366,6 +4367,7 @@ final class ActivityStack {

            RunningTaskInfo ci = new RunningTaskInfo();
            ci.id = task.taskId;
            ci.stackId = (task.stack == null) ? INVALID_STACK_ID : task.stack.getStackId();
            ci.baseActivity = r.intent.getComponent();
            ci.topActivity = top.intent.getComponent();
            ci.lastActiveTime = task.lastActiveTime;