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

Commit 1aa75bfa authored by Max Loh's avatar Max Loh
Browse files

Add check to only notify callbacks for uninstalled packages if they're MBA

Bug: 375000910
Flag: NONE (API has no consumers yet)
Test: Unit tests

Change-Id: I9d3c9ec294242c793648dc78bea158789df8ed21
parent eb85d520
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -404,9 +404,11 @@ public class BackgroundInstallControlService extends SystemService {

    void handlePackageRemove(String packageName, int userId) {
        initBackgroundInstalledPackages();
        if (mBackgroundInstalledPackages.contains(userId, packageName)) {
            mCallbackHelper.notifyAllCallbacks(userId, packageName, INSTALL_EVENT_TYPE_UNINSTALL);
        }
        mBackgroundInstalledPackages.remove(userId, packageName);
        writeBackgroundInstalledPackagesToDisk();
        mCallbackHelper.notifyAllCallbacks(userId, packageName, INSTALL_EVENT_TYPE_UNINSTALL);
    }

    void handleUsageEvent(UsageEvents.Event event, int userId) {
+8 −0
Original line number Diff line number Diff line
@@ -977,11 +977,19 @@ public final class BackgroundInstallControlServiceTest {
        assertEquals(USER_ID_1, UserHandle.getUserId(uid));

        mPackageListObserver.onPackageRemoved(PACKAGE_NAME_1, uid);
        // Test that notifyAllCallbacks doesn't trigger for non-background-installed package
        mPackageListObserver.onPackageRemoved(PACKAGE_NAME_3, uid);
        mTestLooper.dispatchAll();

        assertEquals(1, packages.size());
        assertFalse(packages.contains(USER_ID_1, PACKAGE_NAME_1));
        assertTrue(packages.contains(USER_ID_2, PACKAGE_NAME_2));

        verify(mCallbackHelper)
                .notifyAllCallbacks(
                        USER_ID_1,
                        PACKAGE_NAME_1,
                        BackgroundInstallControlService.INSTALL_EVENT_TYPE_UNINSTALL);
    }

    @Test