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

Commit 34721557 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Fix history crash

In the case of delayed package removal broadcasts

Test: NotificationHistoryManagerTest
Fixes: 310854866
Change-Id: I9d79d1801912ecf296a78216d5bdf5bcf7a9b29e
parent f3024bbc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ public class NotificationHistoryManager {
                for (int i = 0; i < pendingPackageRemovals.size(); i++) {
                    userHistory.onPackageRemoved(pendingPackageRemovals.get(i));
                }
                mUserPendingPackageRemovals.put(userId, null);
                mUserPendingPackageRemovals.remove(userId);
            }

            // delete history if it was disabled when the user was locked
@@ -133,7 +133,7 @@ public class NotificationHistoryManager {
        synchronized (mLock) {
            // Actual data deletion is handled by other parts of the system (the entire directory is
            // removed) - we just need clean up our internal state for GC
            mUserPendingPackageRemovals.put(userId, null);
            mUserPendingPackageRemovals.remove(userId);
            mHistoryEnabled.put(userId, false);
            mUserPendingHistoryDisables.put(userId, false);
            onUserStopped(userId);
+10 −1
Original line number Diff line number Diff line
@@ -183,7 +183,6 @@ public class NotificationHistoryManagerTest extends UiServiceTestCase {
        assertThat(mHistoryManager.doesHistoryExistForUser(mProfileId)).isFalse();
        verify(mDb, times(2)).disableHistory();
    }

    @Test
    public void testAddProfile_historyEnabledInPrimary() {
        // create a history
@@ -610,4 +609,14 @@ public class NotificationHistoryManagerTest extends UiServiceTestCase {

        assertThat(mHistoryManager.isHistoryEnabled(USER_SYSTEM)).isFalse();
    }
    @Test
    public void testDelayedPackageRemoval_userLocked() {
        String pkg = "pkg";
        mHistoryManager.onPackageRemoved(USER_SYSTEM, pkg);
        mHistoryManager.onUserUnlocked(USER_SYSTEM);
        mHistoryManager.onUserStopped(USER_SYSTEM);
        mHistoryManager.onPackageRemoved(USER_SYSTEM, pkg);

        // no exception, yay
    }
}