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

Commit 3802f44a authored by Pavel Grafov's avatar Pavel Grafov Committed by Automerger Merge Worker
Browse files

Merge "Fix locked profile activity hiding logic" into udc-dev am: 0f74f7d7

parents 78248553 0f74f7d7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7025,7 +7025,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Override
    public void notifyLockedProfile(@UserIdInt int userId) {
        mAtmInternal.notifyLockedProfile(userId, mUserController.getCurrentUserId());
        mAtmInternal.notifyLockedProfile(userId);
    }
    @Override
+1 −1
Original line number Diff line number Diff line
@@ -472,7 +472,7 @@ public abstract class ActivityTaskManagerInternal {
    public abstract boolean attachApplication(WindowProcessController wpc) throws RemoteException;

    /** @see IActivityManager#notifyLockedProfile(int) */
    public abstract void notifyLockedProfile(@UserIdInt int userId, int currentUserId);
    public abstract void notifyLockedProfile(@UserIdInt int userId);

    /** @see IActivityManager#startConfirmDeviceCredentialIntent(Intent, Bundle) */
    public abstract void startConfirmDeviceCredentialIntent(Intent intent, Bundle options);
+24 −5
Original line number Diff line number Diff line
@@ -241,6 +241,7 @@ import android.window.SplashScreenView.SplashScreenViewParcelable;
import android.window.TaskSnapshot;

import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.IVoiceInteractor;
import com.android.internal.app.ProcessMap;
@@ -2953,6 +2954,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                    mKeyguardController.setKeyguardShown(displayContent.getDisplayId(),
                            keyguardShowing, aodShowing);
                });
                maybeHideLockedProfileActivityLocked();
            } finally {
                Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
                Binder.restoreCallingIdentity(ident);
@@ -2966,6 +2968,26 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        });
    }

    /**
     * Hides locked profile activity by going to home screen to avoid showing the user two lock
     * screens in a row.
     */
    @GuardedBy("mGlobalLock")
    private void maybeHideLockedProfileActivityLocked() {
        if (!mKeyguardController.isKeyguardLocked(DEFAULT_DISPLAY)
                || mLastResumedActivity == null) {
            return;
        }
        var userInfo = mUserManager.getUserInfo(mLastResumedActivity.mUserId);
        if (userInfo == null || !userInfo.isManagedProfile()) {
            return;
        }
        if (mAmInternal.shouldConfirmCredentials(mLastResumedActivity.mUserId)) {
            mInternal.startHomeActivity(
                    mAmInternal.getCurrentUserId(), "maybeHideLockedProfileActivityLocked");
        }
    }

    // The caller MUST NOT hold the global lock.
    public void onScreenAwakeChanged(boolean isAwake) {
        mH.post(() -> {
@@ -6374,7 +6396,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }

        @Override
        public void notifyLockedProfile(@UserIdInt int userId, int currentUserId) {
        public void notifyLockedProfile(@UserIdInt int userId) {
            try {
                if (!AppGlobals.getPackageManager().isUidPrivileged(Binder.getCallingUid())) {
                    throw new SecurityException("Only privileged app can call notifyLockedProfile");
@@ -6387,10 +6409,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                final long ident = Binder.clearCallingIdentity();
                try {
                    if (mAmInternal.shouldConfirmCredentials(userId)) {
                        if (mKeyguardController.isKeyguardLocked(DEFAULT_DISPLAY)) {
                            // Showing launcher to avoid user entering credential twice.
                            startHomeActivity(currentUserId, "notifyLockedProfile");
                        }
                        maybeHideLockedProfileActivityLocked();
                        mRootWindowContainer.lockAllProfileTasks(userId);
                    }
                } finally {