Loading services/core/java/com/android/server/notification/ManagedServices.java +15 −0 Original line number Diff line number Diff line Loading @@ -1249,6 +1249,21 @@ abstract public class ManagedServices { } } } // Remove uninstalled components from user-set list final ArraySet<String> userSet = mUserSetServices.get(uninstalledUserId); if (userSet != null) { int numServices = userSet.size(); for (int i = numServices - 1; i >= 0; i--) { String pkgOrComponent = userSet.valueAt(i); if (TextUtils.equals(pkg, getPackageName(pkgOrComponent))) { userSet.removeAt(i); if (DEBUG) { Slog.v(TAG, "Removing " + pkgOrComponent + " from user-set list; uninstalled"); } } } } } return removed; } Loading services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -1076,6 +1076,26 @@ public class ManagedServicesTest extends UiServiceTestCase { } } @Test public void testPackageUninstall_componentNoLongerUserSetList() throws Exception { final String pkg = "this.is.a.package.name"; final String component = pkg + "/Ba"; for (int approvalLevel : new int[] { APPROVAL_BY_COMPONENT, APPROVAL_BY_PACKAGE}) { ManagedServices service = new TestManagedServices(getContext(), mLock, mUserProfiles, mIpm, approvalLevel); writeExpectedValuesToSettings(approvalLevel); service.migrateToXml(); final String verifyValue = (approvalLevel == APPROVAL_BY_COMPONENT) ? component : pkg; assertThat(service.isPackageOrComponentAllowed(verifyValue, 0)).isTrue(); assertThat(service.isPackageOrComponentUserSet(verifyValue, 0)).isTrue(); service.onPackagesChanged(true, new String[]{pkg}, new int[]{103}); assertThat(service.isPackageOrComponentUserSet(verifyValue, 0)).isFalse(); } } @Test public void testIsPackageAllowed() { for (int approvalLevel : new int[] {APPROVAL_BY_COMPONENT, APPROVAL_BY_PACKAGE}) { Loading Loading
services/core/java/com/android/server/notification/ManagedServices.java +15 −0 Original line number Diff line number Diff line Loading @@ -1249,6 +1249,21 @@ abstract public class ManagedServices { } } } // Remove uninstalled components from user-set list final ArraySet<String> userSet = mUserSetServices.get(uninstalledUserId); if (userSet != null) { int numServices = userSet.size(); for (int i = numServices - 1; i >= 0; i--) { String pkgOrComponent = userSet.valueAt(i); if (TextUtils.equals(pkg, getPackageName(pkgOrComponent))) { userSet.removeAt(i); if (DEBUG) { Slog.v(TAG, "Removing " + pkgOrComponent + " from user-set list; uninstalled"); } } } } } return removed; } Loading
services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -1076,6 +1076,26 @@ public class ManagedServicesTest extends UiServiceTestCase { } } @Test public void testPackageUninstall_componentNoLongerUserSetList() throws Exception { final String pkg = "this.is.a.package.name"; final String component = pkg + "/Ba"; for (int approvalLevel : new int[] { APPROVAL_BY_COMPONENT, APPROVAL_BY_PACKAGE}) { ManagedServices service = new TestManagedServices(getContext(), mLock, mUserProfiles, mIpm, approvalLevel); writeExpectedValuesToSettings(approvalLevel); service.migrateToXml(); final String verifyValue = (approvalLevel == APPROVAL_BY_COMPONENT) ? component : pkg; assertThat(service.isPackageOrComponentAllowed(verifyValue, 0)).isTrue(); assertThat(service.isPackageOrComponentUserSet(verifyValue, 0)).isTrue(); service.onPackagesChanged(true, new String[]{pkg}, new int[]{103}); assertThat(service.isPackageOrComponentUserSet(verifyValue, 0)).isFalse(); } } @Test public void testIsPackageAllowed() { for (int approvalLevel : new int[] {APPROVAL_BY_COMPONENT, APPROVAL_BY_PACKAGE}) { Loading