Loading services/core/java/com/android/server/pm/BackgroundInstallControlService.java +3 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading services/tests/servicestests/src/com/android/server/pm/BackgroundInstallControlServiceTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
services/core/java/com/android/server/pm/BackgroundInstallControlService.java +3 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading
services/tests/servicestests/src/com/android/server/pm/BackgroundInstallControlServiceTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -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 Loading