diff options
author | Robin Lee <rgl@google.com> | 2014-04-09 16:44:21 +0100 |
---|---|---|
committer | Robin Lee <rgl@google.com> | 2014-04-17 15:58:03 +0100 |
commit | 66e5d96cf9e689148b202787bdc269519c4b6f8f (patch) | |
tree | 244f89ad8343092c4a0363b01812ce646843b33a /services/devicepolicy | |
parent | 379ac2d8b69065eb22ee24d9f3e4d90ec62bc413 (diff) | |
download | frameworks_base-66e5d96cf9e689148b202787bdc269519c4b6f8f.zip frameworks_base-66e5d96cf9e689148b202787bdc269519c4b6f8f.tar.gz frameworks_base-66e5d96cf9e689148b202787bdc269519c4b6f8f.tar.bz2 |
Allow ProfileOwner apps to manage app restrictions
Simple wrapper around the UserManager.{get|set}ApplicationRestrictions
APIs. Also added a new Intent to signal to running apps that the set
of restrictions has changed since startup.
Change-Id: Ifd108108a73f87325b499d9de2e1b2aacc59b264
Diffstat (limited to 'services/devicepolicy')
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 5a458a3..d6f9dea 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -51,6 +51,7 @@ import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.net.ProxyProperties; import android.os.Binder; +import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.IBinder; @@ -3056,4 +3057,44 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } } } + + @Override + public void setApplicationRestrictions(ComponentName who, String packageName, Bundle settings) { + final UserHandle userHandle = new UserHandle(UserHandle.getCallingUserId()); + + synchronized (this) { + if (who == null) { + throw new NullPointerException("ComponentName is null"); + } + getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); + + UserManager um = UserManager.get(mContext); + long id = Binder.clearCallingIdentity(); + try { + um.setApplicationRestrictions(packageName, settings, userHandle); + } finally { + restoreCallingIdentity(id); + } + } + } + + @Override + public Bundle getApplicationRestrictions(ComponentName who, String packageName) { + final UserHandle userHandle = new UserHandle(UserHandle.getCallingUserId()); + + synchronized (this) { + if (who == null) { + throw new NullPointerException("ComponentName is null"); + } + getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); + + UserManager um = UserManager.get(mContext); + long id = Binder.clearCallingIdentity(); + try { + return um.getApplicationRestrictions(packageName, userHandle); + } finally { + restoreCallingIdentity(id); + } + } + } } |