Merge "Trim invalid users" into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
302a7bd34d
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user