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

Commit a3e6b89a authored by Louis Chang's avatar Louis Chang
Browse files

Fix MixedProfileOwnerTest#testLockTask_emergencyDialer failure

Whitelisted package was unable to be started in lock task mode.
We should still perform the lock task violation check if creating
a new task is necessary, instead of refuse the launch directly,
and do it once the new task is created.

Bug: 140908643
Bug: 139449647
Test: atest MixedProfileOwnerTest#testLockTask_emergencyDialer
Test: atest ActivityStarterTests
Change-Id: I3d2516f65708d172d32cf3f3f26d55542247530e
parent 7c03ce7a
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -1535,6 +1535,11 @@ class ActivityStarter {
            final TaskRecord taskToAffiliate = (mLaunchTaskBehind && mSourceRecord != null)
                    ? mSourceRecord.getTaskRecord() : null;
            setNewTask(taskToAffiliate);
            if (mService.getLockTaskController().isLockTaskModeViolation(
                    mStartActivity.getTaskRecord())) {
                Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity);
                return START_RETURN_LOCK_TASK_MODE_VIOLATION;
            }
        } else if (mAddingToTask) {
            addOrReparentStartingActivity(targetTask, "adding to task");
        }
@@ -1654,9 +1659,8 @@ class ActivityStarter {
        final boolean isNewClearTask =
                (mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK))
                        == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK);
        if (mService.getLockTaskController().isInLockTaskMode() && (newTask
                || mService.getLockTaskController().isLockTaskModeViolation(targetTask,
                isNewClearTask))) {
        if (!newTask && mService.getLockTaskController().isLockTaskModeViolation(targetTask,
                isNewClearTask)) {
            Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity);
            return START_RETURN_LOCK_TASK_MODE_VIOLATION;
        }
+0 −7
Original line number Diff line number Diff line
@@ -279,13 +279,6 @@ public class LockTaskController {
        }
    }

    /**
     * @return true if currently in the lock task mode, otherwise, return false.
     */
    boolean isInLockTaskMode() {
        return !mLockTaskModeTasks.isEmpty();
    }

    /**
     * @return whether the requested task is disallowed to be launched.
     */
+0 −1
Original line number Diff line number Diff line
@@ -501,7 +501,6 @@ public class ActivityStarterTests extends ActivityTestsBase {
        final ActivityStarter starter = prepareStarter(0);

        final LockTaskController lockTaskController = mService.getLockTaskController();
        doReturn(true).when(lockTaskController).isInLockTaskMode();
        doReturn(true).when(lockTaskController).isLockTaskModeViolation(any());

        final int result = starter.setReason("testTaskModeViolation").execute();