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

Commit 410e811a authored by Himanshu Gupta's avatar Himanshu Gupta
Browse files

Allowing Private Space unlock without device lock.

Currently, Private profile unlock is disabled if
device lock is not present.
However, private space is still allowed to be created
without device lock via adb commands.

In this change we allow the unlock if the space was created
via adb (by checking user setup complete), when device lock
is not present.

As user setup is always marked complete when PS is created via
Settings entry-point, this change does not effect regular flows.

Bug: 322882655
Test: Manual build and flash
Change-Id: I7e1a3ecd63d78fb3dcca04a78923f98289eb8bf3
parent fd9010cd
Loading
Loading
Loading
Loading
+19 −13
Original line number Original line Diff line number Diff line
@@ -1717,21 +1717,27 @@ public class UserManagerService extends IUserManager.Stub {
                        return false;
                        return false;
                    }
                    }


                    if (android.multiuser.Flags.showSetScreenLockDialog()) {
                        // Show the prompt to set a new screen lock if the device does not have one
                    final KeyguardManager km = mContext.getSystemService(KeyguardManager.class);
                    final KeyguardManager km = mContext.getSystemService(KeyguardManager.class);
                        if (km != null && !km.isDeviceSecure()) {
                    if (km != null && km.isDeviceSecure()) {
                        showConfirmCredentialToDisableQuietMode(userId, target, callingPackage);
                        return false;
                    } else if (km != null && !km.isDeviceSecure()
                            && android.multiuser.Flags.showSetScreenLockDialog()
                            // TODO(b/330720545): Add a better way to accomplish this, also use it
                            //  to block profile creation w/o device credentials present.
                            && Settings.Secure.getIntForUser(mContext.getContentResolver(),
                                Settings.Secure.USER_SETUP_COMPLETE, 0, userId) == 1) {
                        Intent setScreenLockPromptIntent =
                        Intent setScreenLockPromptIntent =
                                SetScreenLockDialogActivity
                                SetScreenLockDialogActivity
                                        .createBaseIntent(LAUNCH_REASON_DISABLE_QUIET_MODE);
                                        .createBaseIntent(LAUNCH_REASON_DISABLE_QUIET_MODE);
                        setScreenLockPromptIntent.putExtra(EXTRA_ORIGIN_USER_ID, userId);
                        setScreenLockPromptIntent.putExtra(EXTRA_ORIGIN_USER_ID, userId);
                        mContext.startActivity(setScreenLockPromptIntent);
                        mContext.startActivity(setScreenLockPromptIntent);
                        return false;
                        return false;
                    } else {
                        Slog.w(LOG_TAG, "Allowing profile unlock even when device credentials "
                                + "are not set for user " + userId);
                    }
                    }
                }
                }
                    showConfirmCredentialToDisableQuietMode(userId, target, callingPackage);
                    return false;
                }
            }
            }
            final boolean hasUnifiedChallenge =
            final boolean hasUnifiedChallenge =
                    mLockPatternUtils.isManagedProfileWithUnifiedChallenge(userId);
                    mLockPatternUtils.isManagedProfileWithUnifiedChallenge(userId);