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

Commit f323e3a5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move the last user save from onCleanupUser to onStopUser" into oc-dev

parents 36fd25ee 01ce92b8
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -173,6 +173,9 @@ public abstract class SystemService {
     * state they maintain for running users.  This is called prior to sending the SHUTDOWN
     * broadcast to the user; it is a good place to stop making use of any resources of that
     * user (such as binding to a service running in the user).
     *
     * <p>NOTE: This is the last callback where the callee may access the target user's CE storage.
     *
     * @param userHandle The identifier of the user.
     */
    public void onStopUser(int userHandle) {}
@@ -181,6 +184,10 @@ public abstract class SystemService {
     * Called when an existing user is stopping, for system services to finalize any per-user
     * state they maintain for running users.  This is called after all application process
     * teardown of the user is complete.
     *
     * <p>NOTE: When this callback is called, the CE storage for the target user may not be
     * accessible already.  Use {@link #onStopUser} instead if you need to access the CE storage.
     *
     * @param userHandle The identifier of the user.
     */
    public void onCleanupUser(int userHandle) {}
+5 −5
Original line number Diff line number Diff line
@@ -555,8 +555,8 @@ public class ShortcutService extends IShortcutService.Stub {
        }

        @Override
        public void onCleanupUser(int userHandle) {
            mService.handleCleanupUser(userHandle);
        public void onStopUser(int userHandle) {
            mService.handleStopUser(userHandle);
        }

        @Override
@@ -606,9 +606,9 @@ public class ShortcutService extends IShortcutService.Stub {
    }

    /** lifecycle event */
    void handleCleanupUser(int userId) {
    void handleStopUser(int userId) {
        if (DEBUG) {
            Slog.d(TAG, "handleCleanupUser: user=" + userId);
            Slog.d(TAG, "handleStopUser: user=" + userId);
        }
        synchronized (mLock) {
            unloadUserLocked(userId);
@@ -3777,7 +3777,7 @@ public class ShortcutService extends IShortcutService.Stub {

                Slog.i(TAG, "cmd: handleUnloadUser: user=" + mUserId);

                ShortcutService.this.handleCleanupUser(mUserId);
                ShortcutService.this.handleStopUser(mUserId);
            }
        }

+2 −2
Original line number Diff line number Diff line
@@ -3241,7 +3241,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest {
        assertNull(mService.getShortcutsForTest().get(USER_10).getLastKnownLauncher());

        // Try stopping the user
        mService.handleCleanupUser(USER_10);
        mService.handleStopUser(USER_10);

        // Now it's unloaded.
        assertEquals(1, mService.getShortcutsForTest().size());
@@ -6106,7 +6106,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest {
            assertEmpty(mManager.getPinnedShortcuts());
        });
        // Send add broadcast, but the user is not running, so should be ignored.
        mService.handleCleanupUser(USER_10);
        mService.handleStopUser(USER_10);
        mRunningUsers.put(USER_10, false);
        mUnlockedUsers.put(USER_10, false);

+1 −1
Original line number Diff line number Diff line
@@ -2091,7 +2091,7 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest {
        assertFalse(mService.isUserUnlockedL(USER_10));

        // Directly call the stop lifecycle event.  Goes back to the initial state.
        mService.handleCleanupUser(USER_0);
        mService.handleStopUser(USER_0);
        assertFalse(mService.isUserUnlockedL(USER_0));
        assertFalse(mService.isUserUnlockedL(USER_10));
    }