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

Commit fe9f143d authored by Jonathan Scott's avatar Jonathan Scott
Browse files

[RESTRICT AUTOMERGE] Make Lock task default behaviour consistent with Settings.

Bug: 127605586
Test: Manual
Change-Id: I5b5b0f9184220a4ed3080ca27792f66d1f5d41aa
parent e5b8c17a
Loading
Loading
Loading
Loading
+20 −12
Original line number Diff line number Diff line
@@ -3942,19 +3942,12 @@ public final class ActivityStackSupervisor implements DisplayListener {
                            mLockTaskNotify = new LockTaskNotify(mService.mContext);
                        }
                        mLockTaskNotify.show(false);
                        try {
                            boolean shouldLockKeyguard = Settings.Secure.getInt(
                                    mService.mContext.getContentResolver(),
                                    Settings.Secure.LOCK_TO_APP_EXIT_LOCKED) != 0;
                            if (mLockTaskModeState == LOCK_TASK_MODE_PINNED && shouldLockKeyguard) {
                        if (mLockTaskModeState == LOCK_TASK_MODE_PINNED && shouldLockKeyguard()) {
                            mWindowManager.lockNow(null);
                            mWindowManager.dismissKeyguard();
                            new LockPatternUtils(mService.mContext)
                                    .requireCredentialEntry(UserHandle.USER_ALL);
                        }
                        } catch (SettingNotFoundException e) {
                            // No setting, don't lock.
                        }
                    } catch (RemoteException ex) {
                        throw new RuntimeException(ex);
                    } finally {
@@ -3990,6 +3983,21 @@ public final class ActivityStackSupervisor implements DisplayListener {
        }
    }

    private boolean shouldLockKeyguard() {
        // This functionality should be kept consistent with
        // com.android.settings.security.ScreenPinningSettings (see b/127605586)
        try {
            return Settings.Secure.getInt(
                    mService.mContext.getContentResolver(),
                    Settings.Secure.LOCK_TO_APP_EXIT_LOCKED) != 0;
        } catch (Settings.SettingNotFoundException e) {
            // Log to SafetyNet for b/127605586
            android.util.EventLog.writeEvent(0x534e4554, "127605586", -1, "");
            LockPatternUtils lockPatternUtils = new LockPatternUtils(mService.mContext);
            return lockPatternUtils.isSecure(mCurrentUser);
        }
    }

    class ActivityContainer extends android.app.IActivityContainer.Stub {
        final static int FORCE_NEW_TASK_FLAGS = FLAG_ACTIVITY_NEW_TASK |
                FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION;