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

Commit a7a61594 authored by Jason Monk's avatar Jason Monk
Browse files

Add lock task checking to moving tasks to back

Chrome seems to use this method of moving itself to the back on
back presses, causing it to escape lock task mode.

Bug: 17365048
Change-Id: I2e8bc614f771951ed96cfc36f9789d12b1742e70
parent f6478d4c
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -8408,6 +8408,10 @@ public final class ActivityManagerService extends ActivityManagerNative
        synchronized(this) {
            TaskRecord tr = recentTaskForIdLocked(taskId);
            if (tr != null) {
                if (tr == mStackSupervisor.mLockTaskModeTask) {
                    mStackSupervisor.showLockTaskToast();
                    return;
                }
                if (DEBUG_STACK) Slog.d(TAG, "moveTaskToBack: moving task=" + tr);
                ActivityStack stack = tr.stack;
                if (stack.mResumedActivity != null && stack.mResumedActivity.task == tr) {
@@ -8440,12 +8444,20 @@ public final class ActivityManagerService extends ActivityManagerNative
        enforceNotIsolatedCaller("moveActivityTaskToBack");
        synchronized(this) {
            final long origId = Binder.clearCallingIdentity();
            try {
                int taskId = ActivityRecord.getTaskForActivityLocked(token, !nonRoot);
                if (taskId >= 0) {
                    if ((mStackSupervisor.mLockTaskModeTask != null)
                            && (mStackSupervisor.mLockTaskModeTask.taskId == taskId)) {
                        mStackSupervisor.showLockTaskToast();
                        return false;
                    }
                    return ActivityRecord.getStackLocked(token).moveTaskToBackLocked(taskId, null);
                }
            } finally {
                Binder.restoreCallingIdentity(origId);
            }
        }
        return false;
    }