diff options
author | Alexandra Gherghina <alexgherghina@google.com> | 2014-04-09 13:54:39 +0100 |
---|---|---|
committer | Alexandra Gherghina <alexgherghina@google.com> | 2014-05-01 11:34:27 +0100 |
commit | df35d570ed25257c6782e632ab1bae5e1603855a (patch) | |
tree | ac137caafe620218393e973206ded3f20ac58302 /services/devicepolicy | |
parent | 7f89c9b8e6724e4316c294eb9f0dde4a46b61e87 (diff) | |
download | frameworks_base-df35d570ed25257c6782e632ab1bae5e1603855a.zip frameworks_base-df35d570ed25257c6782e632ab1bae5e1603855a.tar.gz frameworks_base-df35d570ed25257c6782e632ab1bae5e1603855a.tar.bz2 |
Adds an enabled state in UserInfo instead of DevicePolicyManager
Bug: 14377459
Change-Id: Ib4ec43d87da96c3dddaf9b7ae1796f261863a182
Diffstat (limited to 'services/devicepolicy')
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java | 31 | ||||
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 22 |
2 files changed, 5 insertions, 48 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java b/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java index 3c46e40..1647425 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java @@ -53,7 +53,6 @@ public class DeviceOwner { private static final String ATTR_NAME = "name"; private static final String ATTR_PACKAGE = "package"; private static final String ATTR_USERID = "userId"; - private static final String ATTR_ENABLED = "profileEnabled"; private AtomicFile fileForWriting; @@ -104,8 +103,7 @@ public class DeviceOwner { */ static DeviceOwner createWithProfileOwner(String packageName, String ownerName, int userId) { DeviceOwner owner = new DeviceOwner(); - owner.mProfileOwners.put( - userId, new OwnerInfo(ownerName, packageName, false /* disabled */)); + owner.mProfileOwners.put(userId, new OwnerInfo(ownerName, packageName)); return owner; } @@ -122,7 +120,7 @@ public class DeviceOwner { } void setProfileOwner(String packageName, String ownerName, int userId) { - mProfileOwners.put(userId, new OwnerInfo(ownerName, packageName, false /* disabled */)); + mProfileOwners.put(userId, new OwnerInfo(ownerName, packageName)); } void removeProfileOwner(int userId) { @@ -139,19 +137,6 @@ public class DeviceOwner { return profileOwner != null ? profileOwner.name : null; } - boolean isProfileEnabled(int userId) { - OwnerInfo profileOwner = mProfileOwners.get(userId); - return profileOwner != null ? profileOwner.enabled : true; - } - - void setProfileEnabled(int userId) { - OwnerInfo profileOwner = mProfileOwners.get(userId); - if (profileOwner == null) { - throw new IllegalArgumentException("No profile owner exists."); - } - profileOwner.enabled = true; - } - boolean hasDeviceOwner() { return mDeviceOwner != null; } @@ -203,12 +188,9 @@ public class DeviceOwner { } else if (tag.equals(TAG_PROFILE_OWNER)) { String profileOwnerPackageName = parser.getAttributeValue(null, ATTR_PACKAGE); String profileOwnerName = parser.getAttributeValue(null, ATTR_NAME); - Boolean profileEnabled = Boolean.parseBoolean( - parser.getAttributeValue(null, ATTR_ENABLED)); int userId = Integer.parseInt(parser.getAttributeValue(null, ATTR_USERID)); mProfileOwners.put(userId, - new OwnerInfo( - profileOwnerName, profileOwnerPackageName, profileEnabled)); + new OwnerInfo(profileOwnerName, profileOwnerPackageName)); } else { throw new XmlPullParserException( "Unexpected tag in device owner file: " + tag); @@ -251,7 +233,6 @@ public class DeviceOwner { out.startTag(null, TAG_PROFILE_OWNER); out.attribute(null, ATTR_PACKAGE, owner.getValue().packageName); out.attribute(null, ATTR_NAME, owner.getValue().name); - out.attribute(null, ATTR_ENABLED, String.valueOf(owner.getValue().enabled)); out.attribute(null, ATTR_USERID, Integer.toString(owner.getKey())); out.endTag(null, TAG_PROFILE_OWNER); } @@ -292,12 +273,6 @@ public class DeviceOwner { static class OwnerInfo { public String name; public String packageName; - public boolean enabled = true; // only makes sense for managed profiles - - public OwnerInfo(String name, String packageName, boolean enabled) { - this(name, packageName); - this.enabled = enabled; - } public OwnerInfo(String name, String packageName) { this.name = name; diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index f1ee280..2025771 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -2903,11 +2903,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { int userId = UserHandle.getCallingUserId(); Slog.d(LOG_TAG, "Enabling the profile for: " + userId); - mDeviceOwner.setProfileEnabled(userId); - mDeviceOwner.writeOwnerFile(); - + UserManager um = UserManager.get(mContext); long id = Binder.clearCallingIdentity(); try { + um.setUserEnabled(userId); Intent intent = new Intent(Intent.ACTION_MANAGED_PROFILE_ADDED); intent.putExtra(Intent.EXTRA_USER, new UserHandle(UserHandle.getCallingUserId())); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | @@ -2948,23 +2947,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return null; } - @Override - public boolean isProfileEnabled(int userHandle) { - if (!mHasFeature) { - // If device policy management is not enabled, then the userHandle cannot belong to a - // managed profile. All other profiles are considered enabled. - return true; - } - mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USERS, null); - - synchronized (this) { - if (mDeviceOwner != null) { - return mDeviceOwner.isProfileEnabled(userHandle); - } - } - return true; - } - private boolean isDeviceProvisioned() { return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) > 0; |