diff options
| author | 2017-09-12 22:42:19 +0000 | |
|---|---|---|
| committer | 2017-09-12 22:42:19 +0000 | |
| commit | 302a7bd34de53dbfc81bf4f49b9af7a0e0776fef (patch) | |
| tree | c967f50912434d17b086ba9ef4f34480a85b647e | |
| parent | fedb3f61924fbaf00be4b276ea451aa3e7c14f50 (diff) | |
| parent | 4552300ef2ee59c8f03f2bcdc087d48cb7a58bd3 (diff) | |
Merge "Trim invalid users" into oc-mr1-dev
| -rw-r--r-- | services/core/java/com/android/server/notification/ManagedServices.java | 6 | ||||
| -rw-r--r-- | services/tests/notification/src/com/android/server/notification/ManagedServicesTest.java | 16 |
2 files changed, 21 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/notification/ManagedServices.java b/services/core/java/com/android/server/notification/ManagedServices.java index 91ecb3aad26e..add4184fc129 100644 --- a/services/core/java/com/android/server/notification/ManagedServices.java +++ b/services/core/java/com/android/server/notification/ManagedServices.java @@ -99,6 +99,7 @@ abstract public class ManagedServices { protected final Object mMutex; private final UserProfiles mUserProfiles; private final IPackageManager mPm; + private final UserManager mUm; private final Config mConfig; // contains connections to all connected services, including app services @@ -138,6 +139,7 @@ abstract public class ManagedServices { mPm = pm; mConfig = getConfig(); mApprovalLevel = APPROVAL_BY_COMPONENT; + mUm = (UserManager) mContext.getSystemService(Context.USER_SERVICE); } abstract protected Config getConfig(); @@ -296,7 +298,9 @@ abstract public class ManagedServices { final int userId = XmlUtils.readIntAttribute(parser, ATT_USER_ID, 0); final boolean isPrimary = XmlUtils.readBooleanAttribute(parser, ATT_IS_PRIMARY, true); - addApprovedList(approved, userId, isPrimary); + if (mUm.getUserInfo(userId) != null) { + addApprovedList(approved, userId, isPrimary); + } mUseXml = true; } } diff --git a/services/tests/notification/src/com/android/server/notification/ManagedServicesTest.java b/services/tests/notification/src/com/android/server/notification/ManagedServicesTest.java index 613f01c20300..a4b9b256aa07 100644 --- a/services/tests/notification/src/com/android/server/notification/ManagedServicesTest.java +++ b/services/tests/notification/src/com/android/server/notification/ManagedServicesTest.java @@ -254,6 +254,14 @@ public class ManagedServicesTest extends NotificationTestCase { loadXml(service); verifyExpectedApprovedEntries(service); + + int[] invalidUsers = new int[] {98, 99}; + for (int invalidUser : invalidUsers) { + assertFalse("service type " + service.mApprovalLevel + ":" + + invalidUser + " is allowed for user " + invalidUser, + service.isPackageOrComponentAllowed( + String.valueOf(invalidUser), invalidUser)); + } } } @@ -616,6 +624,14 @@ public class ManagedServicesTest extends NotificationTestCase { xml.append(getXmlEntry( mExpectedSecondary.get(service.mApprovalLevel).get(userId), userId, false)); } + xml.append("<" + ManagedServices.TAG_MANAGED_SERVICES + " " + + ManagedServices.ATT_USER_ID + "=\"99\" " + + ManagedServices.ATT_IS_PRIMARY + "=\"true\" " + + ManagedServices.ATT_APPROVED_LIST + "=\"99\" />\n"); + xml.append("<" + ManagedServices.TAG_MANAGED_SERVICES + " " + + ManagedServices.ATT_USER_ID + "=\"98\" " + + ManagedServices.ATT_IS_PRIMARY + "=\"false\" " + + ManagedServices.ATT_APPROVED_LIST + "=\"98\" />\n"); xml.append("</" + service.getConfig().xmlTag + ">"); XmlPullParser parser = Xml.newPullParser(); |