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

Commit 65317bac authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Properly remove activity from task on start failure." into pi-dev

parents 7c3f7dd9 2b8e0378
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -767,7 +767,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    /**
     * The controller for all operations related to locktask.
     */
    final LockTaskController mLockTaskController;
    private final LockTaskController mLockTaskController;
    final UserController mUserController;
@@ -12441,6 +12441,10 @@ public class ActivityManagerService extends IActivityManager.Stub
        return mActivityStartController;
    }
    LockTaskController getLockTaskController() {
        return mLockTaskController;
    }
    ClientLifecycleManager getLifecycleManager() {
        return mLifecycleManager;
    }
+8 −2
Original line number Diff line number Diff line
@@ -1589,16 +1589,22 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
    void pauseKeyDispatchingLocked() {
        if (!keysPaused) {
            keysPaused = true;

            if (mWindowContainerController != null) {
                mWindowContainerController.pauseKeyDispatching();
            }
        }
    }

    void resumeKeyDispatchingLocked() {
        if (keysPaused) {
            keysPaused = false;

            if (mWindowContainerController != null) {
                mWindowContainerController.resumeKeyDispatching();
            }
        }
    }

    private void updateTaskDescription(CharSequence description) {
        task.lastDescription = description;
+8 −3
Original line number Diff line number Diff line
@@ -3743,7 +3743,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                }

                if (endTask) {
                    mService.mLockTaskController.clearLockedTask(task);
                    mService.getLockTaskController().clearLockedTask(task);
                }
            } else if (!r.isState(PAUSING)) {
                // If the activity is PAUSING, we will complete the finish once
@@ -4639,7 +4639,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai

        // In LockTask mode, moving a locked task to the back of the stack may expose unlocked
        // ones. Therefore we need to check if this operation is allowed.
        if (!mService.mLockTaskController.canMoveTaskToBack(tr)) {
        if (!mService.getLockTaskController().canMoveTaskToBack(tr)) {
            return false;
        }

@@ -5084,7 +5084,12 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            onActivityRemovedFromStack(record);
        }

        mTaskHistory.remove(task);
        final boolean removed = mTaskHistory.remove(task);

        if (removed) {
            EventLog.writeEvent(EventLogTags.AM_REMOVE_TASK, task.taskId, getStackId());
        }

        removeActivitiesFromLRUListLocked(task);
        updateTaskMovement(task, true);

+6 −5
Original line number Diff line number Diff line
@@ -1372,12 +1372,13 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            mService.updateLruProcessLocked(app, true, null);
            mService.updateOomAdjLocked();

            final LockTaskController lockTaskController = mService.getLockTaskController();
            if (task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE
                    || task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE_PRIV
                    || (task.mLockTaskAuth == LOCK_TASK_AUTH_WHITELISTED
                            && mService.mLockTaskController.getLockTaskModeState()
                            && lockTaskController.getLockTaskModeState()
                                    == LOCK_TASK_MODE_LOCKED)) {
                mService.mLockTaskController.startLockTaskMode(task, false, 0 /* blank UID */);
                lockTaskController.startLockTaskMode(task, false, 0 /* blank UID */);
            }

            try {
@@ -2900,7 +2901,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        if (tr != null) {
            tr.removeTaskActivitiesLocked(pauseImmediately, reason);
            cleanUpRemovedTaskLocked(tr, killProcess, removeFromRecents);
            mService.mLockTaskController.clearLockedTask(tr);
            mService.getLockTaskController().clearLockedTask(tr);
            if (tr.isPersistable) {
                mService.notifyTaskPersisterLocked(null, true);
            }
@@ -3814,7 +3815,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        pw.print(mRecentTasks.isRecentsComponentHomeActivity(mCurrentUser));

        getKeyguardController().dump(pw, prefix);
        mService.mLockTaskController.dump(pw, prefix);
        mService.getLockTaskController().dump(pw, prefix);
    }

    public void writeToProto(ProtoOutputStream proto, long fieldId) {
+8 −7
Original line number Diff line number Diff line
@@ -1156,9 +1156,10 @@ class ActivityStarter {
            // If we are not able to proceed, disassociate the activity from the task. Leaving an
            // activity in an incomplete state can lead to issues, such as performing operations
            // without a window container.
            if (!ActivityManager.isStartResultSuccessful(result)
                    && mStartActivity.getTask() != null) {
                mStartActivity.getTask().removeActivity(mStartActivity);
            final ActivityStack stack = mStartActivity.getStack();
            if (!ActivityManager.isStartResultSuccessful(result) && stack != null) {
                stack.finishActivityLocked(mStartActivity, RESULT_CANCELED,
                        null /* intentResultData */, "startActivity", true /* oomAdj */);
            }
            mService.mWindowManager.continueSurfaceLayout();
        }
@@ -1208,7 +1209,7 @@ class ActivityStarter {
            // When the flags NEW_TASK and CLEAR_TASK are set, then the task gets reused but
            // still needs to be a lock task mode violation since the task gets cleared out and
            // the device would otherwise leave the locked task.
            if (mService.mLockTaskController.isLockTaskModeViolation(reusedActivity.getTask(),
            if (mService.getLockTaskController().isLockTaskModeViolation(reusedActivity.getTask(),
                    (mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK))
                            == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK))) {
                Slog.e(TAG, "startActivityUnchecked: Attempt to violate Lock Task Mode");
@@ -2020,7 +2021,7 @@ class ActivityStarter {
            mStartActivity.setTaskToAffiliateWith(taskToAffiliate);
        }

        if (mService.mLockTaskController.isLockTaskModeViolation(mStartActivity.getTask())) {
        if (mService.getLockTaskController().isLockTaskModeViolation(mStartActivity.getTask())) {
            Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity);
            return START_RETURN_LOCK_TASK_MODE_VIOLATION;
        }
@@ -2043,7 +2044,7 @@ class ActivityStarter {
    }

    private int setTaskFromSourceRecord() {
        if (mService.mLockTaskController.isLockTaskModeViolation(mSourceRecord.getTask())) {
        if (mService.getLockTaskController().isLockTaskModeViolation(mSourceRecord.getTask())) {
            Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity);
            return START_RETURN_LOCK_TASK_MODE_VIOLATION;
        }
@@ -2137,7 +2138,7 @@ class ActivityStarter {
    private int setTaskFromInTask() {
        // The caller is asking that the new activity be started in an explicit
        // task it has provided to us.
        if (mService.mLockTaskController.isLockTaskModeViolation(mInTask)) {
        if (mService.getLockTaskController().isLockTaskModeViolation(mInTask)) {
            Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity);
            return START_RETURN_LOCK_TASK_MODE_VIOLATION;
        }
Loading