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

Commit e6d99f13 authored by Rubin Xu's avatar Rubin Xu Committed by Automerger Merge Worker
Browse files

Merge "Do not crash if attempt to launch app from locked profile" into rvc-dev am: 763285e5

Change-Id: I675c61e525963c6d04e37dc34304e11f1c99f90c
parents d3c37d3e 763285e5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -248,7 +248,8 @@ public abstract class ActivityManagerInternal {

    /**
     * Returns whether the given user requires credential entry at this time. This is used to
     * intercept activity launches for work apps when the Work Challenge is present.
     * intercept activity launches for locked work apps due to work challenge being triggered or
     * when the profile user is yet to be unlocked.
     */
    public abstract boolean shouldConfirmCredentials(@UserIdInt int userId);

+12 −8
Original line number Diff line number Diff line
@@ -2218,19 +2218,23 @@ class UserController implements Handler.Callback {

    /**
     * Returns whether the given user requires credential entry at this time. This is used to
     * intercept activity launches for work apps when the Work Challenge is present.
     * intercept activity launches for locked work apps due to work challenge being triggered
     * or when the profile user is yet to be unlocked.
     */
    protected boolean shouldConfirmCredentials(@UserIdInt int userId) {
        synchronized (mLock) {
            if (mStartedUsers.get(userId) == null) {
        if (getStartedUserState(userId) == null) {
            return false;
        }
        }
        if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(userId)) {
        if (!getUserInfo(userId).isManagedProfile()) {
            return false;
        }
        if (mLockPatternUtils.isSeparateProfileChallengeEnabled(userId)) {
            final KeyguardManager km = mInjector.getKeyguardManager();
            return km.isDeviceLocked(userId) && km.isDeviceSecure(userId);
        } else {
            // For unified challenge, need to confirm credential if user is RUNNING_LOCKED.
            return isUserRunning(userId, ActivityManager.FLAG_AND_LOCKED);
        }
    }

    boolean isLockScreenDisabled(@UserIdInt int userId) {
+2 −2
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ class ActivityStartInterceptor {
            // before issuing the work challenge.
            return true;
        }
        return interceptWorkProfileChallengeIfNeeded();
        return interceptLockedManagedProfileIfNeeded();
    }

    private boolean hasCrossProfileAnimation() {
@@ -296,7 +296,7 @@ class ActivityStartInterceptor {
        return true;
    }

    private boolean interceptWorkProfileChallengeIfNeeded() {
    private boolean interceptLockedManagedProfileIfNeeded() {
        final Intent interceptingIntent = interceptWithConfirmCredentialsIfNeeded(mAInfo, mUserId);
        if (interceptingIntent == null) {
            return false;
+1 −1
Original line number Diff line number Diff line
@@ -246,7 +246,7 @@ public class ActivityStartInterceptorTest {
    }

    @Test
    public void testWorkChallenge() {
    public void testLockedManagedProfile() {
        // GIVEN that the user the activity is starting as is currently locked
        when(mAmInternal.shouldConfirmCredentials(TEST_USER_ID)).thenReturn(true);