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

Commit 44189612 authored by Jigar Thakkar's avatar Jigar Thakkar Committed by Android (Google) Code Review
Browse files

Merge "Fix device restarts for private profiles with separate challenge" into main

parents 15501d16 9de43a35
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -537,8 +537,8 @@ public abstract class ActivityManagerInternal {

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

+2 −2
Original line number Diff line number Diff line
@@ -3050,8 +3050,8 @@ class UserController implements Handler.Callback {

    /**
     * Returns whether the given user requires credential entry at this time. This is used to
     * intercept activity launches for locked work apps due to work challenge being triggered
     * or when the profile user is yet to be unlocked.
     * intercept activity launches for apps corresponding to locked profiles due to separate
     * challenge being triggered or when the profile user is yet to be unlocked.
     */
    protected boolean shouldConfirmCredentials(@UserIdInt int userId) {
        if (getStartedUserState(userId) == null) {
+2 −2
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ class ActivityStartInterceptor {
            // before issuing the work challenge.
            return true;
        }
        if (interceptLockedManagedProfileIfNeeded()) {
        if (interceptLockedProfileIfNeeded()) {
            return true;
        }
        if (interceptHomeIfNeeded()) {
@@ -378,7 +378,7 @@ class ActivityStartInterceptor {
        return true;
    }

    private boolean interceptLockedManagedProfileIfNeeded() {
    private boolean interceptLockedProfileIfNeeded() {
        final Intent interceptingIntent = interceptWithConfirmCredentialsIfNeeded(mAInfo, mUserId);
        if (interceptingIntent == null) {
            return false;
+35 −24
Original line number Diff line number Diff line
@@ -579,11 +579,33 @@ class ActivityStarter {
                    computeResolveFilterUid(callingUid, realCallingUid, filterCallingUid),
                    realCallingPid);
            if (resolveInfo == null) {
                // Special case for profiles: If attempting to launch non-crypto aware app in a
                // locked profile or launch an app in a profile that is stopped by quiet mode from
                // an unlocked parent, allow it to resolve as user will be sent via confirm
                // credentials to unlock the profile.
                resolveInfo = resolveIntentForLockedOrStoppedProfiles(supervisor);
            }

            // Collect information about the target of the Intent.
            activityInfo = supervisor.resolveActivity(intent, resolveInfo, startFlags,
                    profilerInfo);

            // Carefully collect grants without holding lock
            if (activityInfo != null) {
                intentGrants = supervisor.mService.mUgmInternal.checkGrantUriPermissionFromIntent(
                        intent, resolvedCallingUid, activityInfo.applicationInfo.packageName,
                        UserHandle.getUserId(activityInfo.applicationInfo.uid));
            }
        }

        /**
         * Resolve intent for locked or stopped profiles if the parent profile is unlocking or
         * unlocked.
         */
        ResolveInfo resolveIntentForLockedOrStoppedProfiles(
                ActivityTaskSupervisor supervisor) {
            final UserInfo userInfo = supervisor.getUserInfo(userId);
                if (userInfo != null && userInfo.isManagedProfile()) {
                    // Special case for managed profiles, if attempting to launch non-cryto aware
                    // app in a locked managed profile from an unlocked parent allow it to resolve
                    // as user will be sent via confirm credentials to unlock the profile.
            if (userInfo != null && userInfo.isProfile()) {
                final UserManager userManager = UserManager.get(supervisor.mService.mContext);
                boolean profileLockedAndParentUnlockingOrUnlocked = false;
                final long token = Binder.clearCallingIdentity();
@@ -596,25 +618,14 @@ class ActivityStarter {
                    Binder.restoreCallingIdentity(token);
                }
                if (profileLockedAndParentUnlockingOrUnlocked) {
                        resolveInfo = supervisor.resolveIntent(intent, resolvedType, userId,
                    return supervisor.resolveIntent(intent, resolvedType, userId,
                            PackageManager.MATCH_DIRECT_BOOT_AWARE
                                    | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
                            computeResolveFilterUid(callingUid, realCallingUid,
                                    filterCallingUid), realCallingPid);
                }
            }
            }

            // Collect information about the target of the Intent.
            activityInfo = supervisor.resolveActivity(intent, resolveInfo, startFlags,
                    profilerInfo);

            // Carefully collect grants without holding lock
            if (activityInfo != null) {
                intentGrants = supervisor.mService.mUgmInternal.checkGrantUriPermissionFromIntent(
                        intent, resolvedCallingUid, activityInfo.applicationInfo.packageName,
                        UserHandle.getUserId(activityInfo.applicationInfo.uid));
            }
            return null;
        }
    }