Loading services/core/java/com/android/server/notification/ManagedServices.java +5 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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(); Loading Loading @@ -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); if (mUm.getUserInfo(userId) != null) { addApprovedList(approved, userId, isPrimary); } mUseXml = true; } } Loading services/tests/notification/src/com/android/server/notification/ManagedServicesTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -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)); } } } Loading Loading @@ -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(); Loading Loading
services/core/java/com/android/server/notification/ManagedServices.java +5 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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(); Loading Loading @@ -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); if (mUm.getUserInfo(userId) != null) { addApprovedList(approved, userId, isPrimary); } mUseXml = true; } } Loading
services/tests/notification/src/com/android/server/notification/ManagedServicesTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -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)); } } } Loading Loading @@ -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(); Loading