summaryrefslogtreecommitdiffstats
path: root/services/devicepolicy
diff options
context:
space:
mode:
authorAlexandra Gherghina <alexgherghina@google.com>2014-04-02 11:23:54 +0100
committerAlexandra Gherghina <alexgherghina@google.com>2014-04-11 16:51:49 +0100
commit512675b07d1643f018e84d66e4ee8b641d3e191c (patch)
tree8d54bdaaa211432f3eff9a7c8aaf14e84127ba18 /services/devicepolicy
parent39c82a3b19788b100f52f24732560ef325c13133 (diff)
downloadframeworks_base-512675b07d1643f018e84d66e4ee8b641d3e191c.zip
frameworks_base-512675b07d1643f018e84d66e4ee8b641d3e191c.tar.gz
frameworks_base-512675b07d1643f018e84d66e4ee8b641d3e191c.tar.bz2
Add new call to DevicePolicyManager to enable a profile.
Bug: 13755091 Change-Id: Idb6975431f842ededf78966c578b0533e6f186af
Diffstat (limited to 'services/devicepolicy')
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java26
1 files changed, 26 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 983ca2d..35f9314 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -2888,6 +2888,32 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
@Override
+ public void setProfileEnabled(ComponentName who) {
+ if (!mHasFeature) {
+ return;
+ }
+ synchronized (this) {
+ // Check for permissions
+ if (who == null) {
+ throw new NullPointerException("ComponentName is null");
+ }
+ // Check if this is the profile owner who is calling
+ getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ Slog.d(LOG_TAG, "Enabling the profile for: " + UserHandle.getCallingUserId());
+ long id = Binder.clearCallingIdentity();
+
+ try {
+ 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);
+ mContext.sendBroadcastAsUser(intent, UserHandle.OWNER);
+ } finally {
+ restoreCallingIdentity(id);
+ }
+ }
+ }
+
+ @Override
public String getProfileOwner(int userHandle) {
if (!mHasFeature) {
return null;