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

Commit dd1e66f7 authored by Jiaquan He's avatar Jiaquan He
Browse files

Add more onTopLauncher support.

- Add onTopLauncher checking for TaskRecord.
- Add onTopLauncher to the window manager.

Bug: 28425537
Change-Id: Ic9e53db891dc42463a1a77b106ba93438a052181
parent d2a4944d
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -107,12 +107,14 @@ interface IWindowManager
     *                        they are in.
     *                        they are in.
     * @param homeTask True if this is the task.
     * @param homeTask True if this is the task.
     * @param targetSdkVersion The application's target SDK version
     * @param targetSdkVersion The application's target SDK version
     * @param isOnTopLauncher True if this task is an on-top launcher.
     */
     */
    void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId,
    void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId,
            int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId,
            int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId,
            int configChanges, boolean voiceInteraction, boolean launchTaskBehind,
            int configChanges, boolean voiceInteraction, boolean launchTaskBehind,
            in Rect taskBounds, in Configuration configuration, int taskResizeMode,
            in Rect taskBounds, in Configuration configuration, int taskResizeMode,
            boolean alwaysFocusable, boolean homeTask, int targetSdkVersion, int rotationAnimationHint);
            boolean alwaysFocusable, boolean homeTask, int targetSdkVersion,
            int rotationAnimationHint, boolean isOnTopLauncher);
    /**
    /**
     *
     *
     * @param token The token we are adding to the input task Id.
     * @param token The token we are adding to the input task Id.
@@ -124,9 +126,10 @@ interface IWindowManager
     * @param config Configuration that is being used with this task.
     * @param config Configuration that is being used with this task.
     * @param taskResizeMode The resize mode of the task.
     * @param taskResizeMode The resize mode of the task.
     * @param homeTask True if this is the task.
     * @param homeTask True if this is the task.
     * @param isOnTopLauncher True if this task is an on-top launcher.
     */
     */
    void setAppTask(IBinder token, int taskId, int stackId, in Rect taskBounds,
    void setAppTask(IBinder token, int taskId, int stackId, in Rect taskBounds,
            in Configuration config, int taskResizeMode, boolean homeTask);
            in Configuration config, int taskResizeMode, boolean homeTask, boolean isOnTopLauncher);
    void setAppOrientation(IApplicationToken token, int requestedOrientation);
    void setAppOrientation(IApplicationToken token, int requestedOrientation);
    int getAppOrientation(IApplicationToken token);
    int getAppOrientation(IApplicationToken token);
    void setFocusedApp(IBinder token, boolean moveFocusNow);
    void setFocusedApp(IBinder token, boolean moveFocusNow);
+2 −2
Original line number Original line Diff line number Diff line
@@ -5209,7 +5209,7 @@ final class ActivityStack {
                (r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId, r.info.configChanges,
                (r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId, r.info.configChanges,
                task.voiceSession != null, r.mLaunchTaskBehind, bounds, task.mOverrideConfig,
                task.voiceSession != null, r.mLaunchTaskBehind, bounds, task.mOverrideConfig,
                task.mResizeMode, r.isAlwaysFocusable(), task.isHomeTask(),
                task.mResizeMode, r.isAlwaysFocusable(), task.isHomeTask(),
                r.appInfo.targetSdkVersion, r.mRotationAnimationHint);
                r.appInfo.targetSdkVersion, r.mRotationAnimationHint, task.isOnTopLauncher());
        r.taskConfigOverride = task.mOverrideConfig;
        r.taskConfigOverride = task.mOverrideConfig;
    }
    }


@@ -5262,7 +5262,7 @@ final class ActivityStack {
    private void setAppTask(ActivityRecord r, TaskRecord task) {
    private void setAppTask(ActivityRecord r, TaskRecord task) {
        final Rect bounds = task.updateOverrideConfigurationFromLaunchBounds();
        final Rect bounds = task.updateOverrideConfigurationFromLaunchBounds();
        mWindowManager.setAppTask(r.appToken, task.taskId, mStackId, bounds, task.mOverrideConfig,
        mWindowManager.setAppTask(r.appToken, task.taskId, mStackId, bounds, task.mOverrideConfig,
                task.mResizeMode, task.isHomeTask());
                task.mResizeMode, task.isHomeTask(), task.isOnTopLauncher());
        r.taskConfigOverride = task.mOverrideConfig;
        r.taskConfigOverride = task.mOverrideConfig;
    }
    }


+8 −0
Original line number Original line Diff line number Diff line
@@ -66,6 +66,7 @@ import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
import static android.content.Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS;
import static android.content.Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS;
import static android.content.pm.ActivityInfo.FLAG_ON_TOP_LAUNCHER;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_ALWAYS;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_ALWAYS;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_DEFAULT;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_DEFAULT;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED;
@@ -176,6 +177,8 @@ final class TaskRecord {
                            // ActivityManager.LOCK_TASK_LAUNCH_MODE_*
                            // ActivityManager.LOCK_TASK_LAUNCH_MODE_*
    private boolean mPrivileged;    // The root activity application of this task holds
    private boolean mPrivileged;    // The root activity application of this task holds
                                    // privileged permissions.
                                    // privileged permissions.
    private boolean mIsOnTopLauncher; // Whether this task is an on-top launcher. See
                                      // android.R.attr#onTopLauncher.


    /** Can't be put in lockTask mode. */
    /** Can't be put in lockTask mode. */
    final static int LOCK_TASK_AUTH_DONT_LOCK = 0;
    final static int LOCK_TASK_AUTH_DONT_LOCK = 0;
@@ -474,6 +477,7 @@ final class TaskRecord {
            autoRemoveRecents = false;
            autoRemoveRecents = false;
        }
        }
        mResizeMode = info.resizeMode;
        mResizeMode = info.resizeMode;
        mIsOnTopLauncher = (info.flags & FLAG_ON_TOP_LAUNCHER) != 0;
        mLockTaskMode = info.lockTaskLaunchMode;
        mLockTaskMode = info.lockTaskLaunchMode;
        mPrivileged = (info.applicationInfo.privateFlags & PRIVATE_FLAG_PRIVILEGED) != 0;
        mPrivileged = (info.applicationInfo.privateFlags & PRIVATE_FLAG_PRIVILEGED) != 0;
        setLockTaskAuth();
        setLockTaskAuth();
@@ -1024,6 +1028,10 @@ final class TaskRecord {
                || ActivityInfo.isResizeableMode(mResizeMode)) && !mTemporarilyUnresizable;
                || ActivityInfo.isResizeableMode(mResizeMode)) && !mTemporarilyUnresizable;
    }
    }


    boolean isOnTopLauncher() {
        return isHomeTask() && mIsOnTopLauncher;
    }

    boolean inCropWindowsResizeMode() {
    boolean inCropWindowsResizeMode() {
        return !isResizeable() && mResizeMode == RESIZE_MODE_CROP_WINDOWS;
        return !isResizeable() && mResizeMode == RESIZE_MODE_CROP_WINDOWS;
    }
    }
+9 −1
Original line number Original line Diff line number Diff line
@@ -92,12 +92,16 @@ class Task implements DimLayer.DimLayerUser {


    private boolean mHomeTask;
    private boolean mHomeTask;


    // Whether this task is an on-top launcher task, which is determined by the root activity.
    private boolean mIsOnTopLauncher;

    Task(int taskId, TaskStack stack, int userId, WindowManagerService service, Rect bounds,
    Task(int taskId, TaskStack stack, int userId, WindowManagerService service, Rect bounds,
            Configuration config) {
            Configuration config, boolean isOnTopLauncher) {
        mTaskId = taskId;
        mTaskId = taskId;
        mStack = stack;
        mStack = stack;
        mUserId = userId;
        mUserId = userId;
        mService = service;
        mService = service;
        mIsOnTopLauncher = isOnTopLauncher;
        setBounds(bounds, config);
        setBounds(bounds, config);
    }
    }


@@ -282,6 +286,10 @@ class Task implements DimLayer.DimLayerUser {
                && (ActivityInfo.isResizeableMode(mResizeMode) || mService.mForceResizableTasks);
                && (ActivityInfo.isResizeableMode(mResizeMode) || mService.mForceResizableTasks);
    }
    }


    boolean isOnTopLauncher() {
        return mIsOnTopLauncher;
    }

    boolean cropWindowsToStackBounds() {
    boolean cropWindowsToStackBounds() {
        return !mHomeTask && (isResizeable() || mResizeMode == RESIZE_MODE_CROP_WINDOWS);
        return !mHomeTask && (isResizeable() || mResizeMode == RESIZE_MODE_CROP_WINDOWS);
    }
    }
+9 −6
Original line number Original line Diff line number Diff line
@@ -3362,7 +3362,7 @@ public class WindowManagerService extends IWindowManager.Stub
    }
    }


    private Task createTaskLocked(int taskId, int stackId, int userId, AppWindowToken atoken,
    private Task createTaskLocked(int taskId, int stackId, int userId, AppWindowToken atoken,
            Rect bounds, Configuration config) {
            Rect bounds, Configuration config, boolean isOnTopLauncher) {
        if (DEBUG_STACK) Slog.i(TAG_WM, "createTaskLocked: taskId=" + taskId + " stackId=" + stackId
        if (DEBUG_STACK) Slog.i(TAG_WM, "createTaskLocked: taskId=" + taskId + " stackId=" + stackId
                + " atoken=" + atoken + " bounds=" + bounds);
                + " atoken=" + atoken + " bounds=" + bounds);
        final TaskStack stack = mStackIdToStack.get(stackId);
        final TaskStack stack = mStackIdToStack.get(stackId);
@@ -3370,7 +3370,7 @@ public class WindowManagerService extends IWindowManager.Stub
            throw new IllegalArgumentException("addAppToken: invalid stackId=" + stackId);
            throw new IllegalArgumentException("addAppToken: invalid stackId=" + stackId);
        }
        }
        EventLog.writeEvent(EventLogTags.WM_TASK_CREATED, taskId, stackId);
        EventLog.writeEvent(EventLogTags.WM_TASK_CREATED, taskId, stackId);
        Task task = new Task(taskId, stack, userId, this, bounds, config);
        Task task = new Task(taskId, stack, userId, this, bounds, config, isOnTopLauncher);
        mTaskIdToTask.put(taskId, task);
        mTaskIdToTask.put(taskId, task);
        stack.addTask(task, !atoken.mLaunchTaskBehind /* toTop */, atoken.showForAllUsers);
        stack.addTask(task, !atoken.mLaunchTaskBehind /* toTop */, atoken.showForAllUsers);
        return task;
        return task;
@@ -3381,7 +3381,8 @@ public class WindowManagerService extends IWindowManager.Stub
            int requestedOrientation, boolean fullscreen, boolean showForAllUsers, int userId,
            int requestedOrientation, boolean fullscreen, boolean showForAllUsers, int userId,
            int configChanges, boolean voiceInteraction, boolean launchTaskBehind,
            int configChanges, boolean voiceInteraction, boolean launchTaskBehind,
            Rect taskBounds, Configuration config, int taskResizeMode, boolean alwaysFocusable,
            Rect taskBounds, Configuration config, int taskResizeMode, boolean alwaysFocusable,
            boolean homeTask, int targetSdkVersion, int rotationAnimationHint) {
            boolean homeTask, int targetSdkVersion, int rotationAnimationHint,
            boolean isOnTopLauncher) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "addAppToken()")) {
                "addAppToken()")) {
            throw new SecurityException("Requires MANAGE_APP_TOKENS permission");
            throw new SecurityException("Requires MANAGE_APP_TOKENS permission");
@@ -3423,7 +3424,8 @@ public class WindowManagerService extends IWindowManager.Stub


            Task task = mTaskIdToTask.get(taskId);
            Task task = mTaskIdToTask.get(taskId);
            if (task == null) {
            if (task == null) {
                task = createTaskLocked(taskId, stackId, userId, atoken, taskBounds, config);
                task = createTaskLocked(taskId, stackId, userId, atoken, taskBounds, config,
                        isOnTopLauncher);
            }
            }
            task.addAppToken(addPos, atoken, taskResizeMode, homeTask);
            task.addAppToken(addPos, atoken, taskResizeMode, homeTask);


@@ -3437,7 +3439,7 @@ public class WindowManagerService extends IWindowManager.Stub


    @Override
    @Override
    public void setAppTask(IBinder token, int taskId, int stackId, Rect taskBounds,
    public void setAppTask(IBinder token, int taskId, int stackId, Rect taskBounds,
            Configuration config, int taskResizeMode, boolean homeTask) {
            Configuration config, int taskResizeMode, boolean homeTask, boolean isOnTopLauncher) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "setAppTask()")) {
                "setAppTask()")) {
            throw new SecurityException("Requires MANAGE_APP_TOKENS permission");
            throw new SecurityException("Requires MANAGE_APP_TOKENS permission");
@@ -3455,7 +3457,8 @@ public class WindowManagerService extends IWindowManager.Stub
            Task newTask = mTaskIdToTask.get(taskId);
            Task newTask = mTaskIdToTask.get(taskId);
            if (newTask == null) {
            if (newTask == null) {
                newTask = createTaskLocked(
                newTask = createTaskLocked(
                        taskId, stackId, oldTask.mUserId, atoken, taskBounds, config);
                        taskId, stackId, oldTask.mUserId, atoken, taskBounds, config,
                        isOnTopLauncher);
            }
            }
            newTask.addAppToken(Integer.MAX_VALUE /* at top */, atoken, taskResizeMode, homeTask);
            newTask.addAppToken(Integer.MAX_VALUE /* at top */, atoken, taskResizeMode, homeTask);
        }
        }
Loading