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

Commit 4cb99331 authored by Keun young Park's avatar Keun young Park
Browse files

Add IActivityManager.stopUserWithDelayedLocking

- Only allow delayed locking for the explicit call, stopUserWithDelayedLocking()
  or for implicit user stopping caused by user switching.
- All other explicit user stopping should immediately lock the user. This allows
  immediate locking from component like DevicePolicy.
- Product still should enable delayed locking explicitly and if it is disabled,
  IActivityManager.stopUserWithDelayedLocking will behave the same with
  IActivityManager.stopUser.
- Once user is stopped in delayed locking mode, one of following steps can completely
  lock the user (this is not a complete list):
  1. User is asked to be stopped with IActivityManager.stopUser call.
  2. User is restarted through IActivityManager.restartUserInBackground call.
  3. UserManager.evictCredentialEncryptyionKey (involves restartUserInBackground call)
  4. When user is removed (involves IActivityManager.stopUser call).

Bug: 131757355
Test: run unit tests
      check user locking in car device where delayed locking is enabled.

Change-Id: I663ffde3a5b74738a6f59b4282ff562146f22662
parent 72973ef6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -345,6 +345,12 @@ interface IActivityManager {
            in Bundle options, int userId);
    @UnsupportedAppUsage
    int stopUser(int userid, boolean force, in IStopUserCallback callback);
    /**
     * Check {@link com.android.server.am.ActivityManagerService#stopUserWithDelayedLocking(int, boolean, IStopUserCallback)}
     * for details.
     */
    int stopUserWithDelayedLocking(int userid, boolean force, in IStopUserCallback callback);

    @UnsupportedAppUsage
    void registerUserSwitchObserver(in IUserSwitchObserver observer, in String name);
    void unregisterUserSwitchObserver(in IUserSwitchObserver observer);
+31 −6
Original line number Diff line number Diff line
@@ -9108,13 +9108,14 @@ public class ActivityManagerService extends IActivityManager.Stub
            final Resources res = mContext.getResources();
            mAppErrors.loadAppsNotReportingCrashesFromConfigLocked(res.getString(
                    com.android.internal.R.string.config_appsNotReportingCrashes));
            mUserController.mUserSwitchUiEnabled = !res.getBoolean(
            final boolean userSwitchUiEnabled = !res.getBoolean(
                    com.android.internal.R.bool.config_customUserSwitchUi);
            mUserController.mMaxRunningUsers = res.getInteger(
            final int maxRunningUsers = res.getInteger(
                    com.android.internal.R.integer.config_multiuserMaxRunningUsers);
            mUserController.mDelayUserDataLocking = res.getBoolean(
            final boolean delayUserDataLocking = res.getBoolean(
                    com.android.internal.R.bool.config_multiuserDelayUserDataLocking);
            mUserController.setInitialConfig(userSwitchUiEnabled, maxRunningUsers,
                    delayUserDataLocking);
            mWaitForNetworkTimeoutMs = waitForNetworkTimeoutMs;
            mPssDeferralTime = pssDeferralMs;
        }
@@ -17926,7 +17927,31 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Override
    public int stopUser(final int userId, boolean force, final IStopUserCallback callback) {
        return mUserController.stopUser(userId, force, callback, null /* keyEvictedCallback */);
        return mUserController.stopUser(userId, force, /* allowDelayedLocking= */ false,
                /* callback= */ callback, /* keyEvictedCallback= */ null);
    }
    /**
     * Stops user but allow delayed locking. Delayed locking keeps user unlocked even after
     * stopping only if {@code config_multiuserDelayUserDataLocking} overlay is set true.
     *
     * <p>When delayed locking is not enabled through the overlay, this call becomes the same
     * with {@link #stopUser(int, boolean, IStopUserCallback)} call.
     *
     * @param userId User id to stop.
     * @param force Force stop the user even if the user is related with system user or current
     *              user.
     * @param callback Callback called when user has stopped.
     *
     * @return {@link ActivityManager#USER_OP_SUCCESS} when user is stopped successfully. Returns
     *         other {@code ActivityManager#USER_OP_*} codes for failure.
     *
     */
    @Override
    public int stopUserWithDelayedLocking(final int userId, boolean force,
            final IStopUserCallback callback) {
        return mUserController.stopUser(userId, force, /* allowDelayedLocking= */ true,
                /* callback= */ callback, /* keyEvictedCallback= */ null);
    }
    @Override
@@ -18332,7 +18357,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        @Override
        public int getMaxRunningUsers() {
            return mUserController.mMaxRunningUsers;
            return mUserController.getMaxRunningUsers();
        }
        @Override
+155 −56

File changed.

Preview size limit exceeded, changes collapsed.

+101 −11

File changed.

Preview size limit exceeded, changes collapsed.