diff options
author | Robin Lee <rgl@google.com> | 2014-07-22 16:47:40 +0100 |
---|---|---|
committer | Robin Lee <rgl@google.com> | 2014-07-22 21:35:09 +0000 |
commit | 9c2be6c7ba3d7dce58e8f4ec1617698c54ae808e (patch) | |
tree | b699b5cab393ed587f17cb07f05764ba02c585dd | |
parent | 2dcab18c6c9381122df6e06a93912e53dff69408 (diff) | |
download | frameworks_base-9c2be6c7ba3d7dce58e8f4ec1617698c54ae808e.zip frameworks_base-9c2be6c7ba3d7dce58e8f4ec1617698c54ae808e.tar.gz frameworks_base-9c2be6c7ba3d7dce58e8f4ec1617698c54ae808e.tar.bz2 |
Stop double-loading device admins
loadSettingsLocked() was being called twice for USER_OWNER at
systemReady(), doubling the number of admin entries at every boot.
Also guards against double-adding admins which appear twice in the
same XML file, favouring more recently-refreshed entries for
backward compatibility.
Previously an application calling in with 'refreshing = true' would
double-insert whatever admin was being refreshed into its user's list
of device admins. This is fixed too.
@bug 16416936
Change-Id: Idd147aa130e6bce7bcc40532f0a7fb07117b3151
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 2a11252..5f876ff 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -1103,6 +1103,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { type = parser.next(); int outerDepth = parser.getDepth(); policy.mLockTaskPackages.clear(); + policy.mAdminList.clear(); + policy.mAdminMap.clear(); while ((type=parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { @@ -1124,7 +1126,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { ActiveAdmin ap = new ActiveAdmin(dai); ap.readFromXml(parser); policy.mAdminMap.put(ap.info.getComponent(), ap); - policy.mAdminList.add(ap); } } catch (RuntimeException e) { Slog.w(LOG_TAG, "Failed loading admin " + name, e); @@ -1184,6 +1185,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { // Ignore } + // Generate a list of admins from the admin map + policy.mAdminList.addAll(policy.mAdminMap.values()); + // Validate that what we stored for the password quality matches // sufficiently what is currently set. Note that this is only // a sanity check in case the two get out of sync; this should @@ -1268,10 +1272,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (!mHasFeature) { return; } - synchronized (this) { - loadSettingsLocked(getUserData(UserHandle.USER_OWNER), UserHandle.USER_OWNER); - loadDeviceOwner(); - } + getUserData(UserHandle.USER_OWNER); + loadDeviceOwner(); cleanUpOldUsers(); mAppOpsService = IAppOpsService.Stub.asInterface( ServiceManager.getService(Context.APP_OPS_SERVICE)); @@ -1436,14 +1438,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { ActiveAdmin newAdmin = new ActiveAdmin(info); policy.mAdminMap.put(adminReceiver, newAdmin); int replaceIndex = -1; - if (refreshing) { - final int N = policy.mAdminList.size(); - for (int i=0; i < N; i++) { - ActiveAdmin oldAdmin = policy.mAdminList.get(i); - if (oldAdmin.info.getComponent().equals(adminReceiver)) { - replaceIndex = i; - break; - } + final int N = policy.mAdminList.size(); + for (int i=0; i < N; i++) { + ActiveAdmin oldAdmin = policy.mAdminList.get(i); + if (oldAdmin.info.getComponent().equals(adminReceiver)) { + replaceIndex = i; + break; } } if (replaceIndex == -1) { |