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

Commit 96986f64 authored by Yanli Wan's avatar Yanli Wan Committed by Automerger Merge Worker
Browse files

Merge "Stop app pinning if lock task is requested from allowedlisted app" into...

Merge "Stop app pinning if lock task is requested from allowedlisted app" into tm-qpr-dev am: 3544e25a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19461336



Change-Id: I8546e339d3627dc8d3df4cf8e58064ae2628a1fe
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents dc308a9d 3544e25a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1069,6 +1069,12 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-1075136930": {
      "message": "startLockTaskMode: Can't lock due to auth",
      "level": "WARN",
      "group": "WM_DEBUG_LOCKTASK",
      "at": "com\/android\/server\/wm\/LockTaskController.java"
    },
    "-1069336896": {
      "message": "onRootTaskOrderChanged(): rootTask=%s",
      "level": "DEBUG",
+3 −0
Original line number Diff line number Diff line
@@ -2568,6 +2568,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                    }
                    task = r.getTask();
                }
                // If {@code isSystemCaller} is {@code true}, it means the user intends to stop
                // pinned mode through UI; otherwise, it's called by an app and we need to stop
                // locked or pinned mode, subject to checks.
                getLockTaskController().stopLockTaskMode(task, isSystemCaller, callingUid);
            }
            // Launch in-call UI if a call is ongoing. This is necessary to allow stopping the lock
+14 −8
Original line number Diff line number Diff line
@@ -481,27 +481,24 @@ public class LockTaskController {
     *
     * @param task the task that requested the end of lock task mode ({@code null} for quitting app
     *             pinning mode)
     * @param isSystemCaller indicates whether this request comes from the system via
     *                       {@link ActivityTaskManagerService#stopSystemLockTaskMode()}. If
     *                       {@code true}, it means the user intends to stop pinned mode through UI;
     *                       otherwise, it's called by an app and we need to stop locked or pinned
     *                       mode, subject to checks.
     * @param stopAppPinning indicates whether to stop app pinning mode or to stop a task from
     *                       being locked.
     * @param callingUid the caller that requested the end of lock task mode.
     * @throws IllegalArgumentException if the calling task is invalid (e.g., {@code null} or not in
     *                                  foreground)
     * @throws SecurityException if the caller is not authorized to stop the lock task mode, i.e. if
     *                           they differ from the one that launched lock task mode.
     */
    void stopLockTaskMode(@Nullable Task task, boolean isSystemCaller, int callingUid) {
    void stopLockTaskMode(@Nullable Task task, boolean stopAppPinning, int callingUid) {
        if (mLockTaskModeState == LOCK_TASK_MODE_NONE) {
            return;
        }

        if (isSystemCaller) {
        if (stopAppPinning) {
            if (mLockTaskModeState == LOCK_TASK_MODE_PINNED) {
                clearLockedTasks("stopAppPinning");
            } else {
                Slog.e(TAG_LOCKTASK, "Attempted to stop LockTask with isSystemCaller=true");
                Slog.e(TAG_LOCKTASK, "Attempted to stop app pinning while fully locked");
                showLockTaskToast();
            }

@@ -642,6 +639,10 @@ public class LockTaskController {
     * @param callingUid the caller that requested the launch of lock task mode.
     */
    void startLockTaskMode(@NonNull Task task, boolean isSystemCaller, int callingUid) {
        if (task.mLockTaskAuth == LOCK_TASK_AUTH_DONT_LOCK) {
            ProtoLog.w(WM_DEBUG_LOCKTASK, "startLockTaskMode: Can't lock due to auth");
            return;
        }
        if (!isSystemCaller) {
            task.mLockTaskUid = callingUid;
            if (task.mLockTaskAuth == LOCK_TASK_AUTH_PINNABLE) {
@@ -654,6 +655,11 @@ public class LockTaskController {
                    statusBarManager.showScreenPinningRequest(task.mTaskId);
                }
                return;
            } else if (mLockTaskModeState == LOCK_TASK_MODE_PINNED) {
                // startLockTask() called by app, and app is part of lock task allowlist.
                // Deactivate the currently pinned task before doing so.
                Slog.i(TAG, "Stop app pinning before entering full lock task mode");
                stopLockTaskMode(/* task= */ null, /* stopAppPinning= */ true, callingUid);
            }
        }