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

Commit 24a1ea3f authored by Danning Chen's avatar Danning Chen Committed by Android (Google) Code Review
Browse files

Merge "Fix the bug that queries UsageStatsService for locked users" into rvc-dev

parents eaebc654 18fecf78
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -72,13 +72,13 @@ public class PeopleService extends SystemService {
    }

    @Override
    public void onUserUnlocking(@NonNull TargetUser targetUser) {
        mDataManager.onUserUnlocked(targetUser.getUserIdentifier());
    public void onUserUnlocked(@NonNull TargetUser user) {
        mDataManager.onUserUnlocked(user.getUserIdentifier());
    }

    @Override
    public void onUserStopping(@NonNull TargetUser targetUser) {
        mDataManager.onUserStopped(targetUser.getUserIdentifier());
    public void onUserStopping(@NonNull TargetUser user) {
        mDataManager.onUserStopping(user.getUserIdentifier());
    }

    @VisibleForTesting
+3 −3
Original line number Diff line number Diff line
@@ -198,13 +198,13 @@ public class DataManager {
        DataMaintenanceService.scheduleJob(mContext, userId);
    }

    /** This method is called when a user is stopped. */
    public void onUserStopped(int userId) {
    /** This method is called when a user is stopping. */
    public void onUserStopping(int userId) {
        if (mUserDataArray.indexOfKey(userId) >= 0) {
            mUserDataArray.get(userId).setUserStopped();
        }
        if (mUsageStatsQueryFutures.indexOfKey(userId) >= 0) {
            mUsageStatsQueryFutures.valueAt(userId).cancel(true);
            mUsageStatsQueryFutures.get(userId).cancel(true);
        }
        if (mBroadcastReceivers.indexOfKey(userId) >= 0) {
            mContext.unregisterReceiver(mBroadcastReceivers.get(userId));
+1 −1
Original line number Diff line number Diff line
@@ -269,7 +269,7 @@ public final class DataManagerTest {
        assertEquals(1, conversations.size());
        assertEquals("sc_1", conversations.get(0).getShortcutId());

        mDataManager.onUserStopped(USER_ID_PRIMARY);
        mDataManager.onUserStopping(USER_ID_PRIMARY);
        conversations = getConversationsInPrimary();
        assertTrue(conversations.isEmpty());
    }