Merge "Add new call to DevicePolicyManager to enable a profile."
This commit is contained in:
committed by
Android (Google) Code Review
commit
23d2dd3da1
@@ -4953,6 +4953,7 @@ package android.app.admin {
|
|||||||
method public void setPasswordMinimumSymbols(android.content.ComponentName, int);
|
method public void setPasswordMinimumSymbols(android.content.ComponentName, int);
|
||||||
method public void setPasswordMinimumUpperCase(android.content.ComponentName, int);
|
method public void setPasswordMinimumUpperCase(android.content.ComponentName, int);
|
||||||
method public void setPasswordQuality(android.content.ComponentName, int);
|
method public void setPasswordQuality(android.content.ComponentName, int);
|
||||||
|
method public void setProfileEnabled(android.content.ComponentName);
|
||||||
method public int setStorageEncryption(android.content.ComponentName, boolean);
|
method public int setStorageEncryption(android.content.ComponentName, boolean);
|
||||||
method public void wipeData(int);
|
method public void wipeData(int);
|
||||||
field public static final java.lang.String ACTION_ADD_DEVICE_ADMIN = "android.app.action.ADD_DEVICE_ADMIN";
|
field public static final java.lang.String ACTION_ADD_DEVICE_ADMIN = "android.app.action.ADD_DEVICE_ADMIN";
|
||||||
|
|||||||
@@ -1755,9 +1755,27 @@ public class DevicePolicyManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the enabled state of the profile. A profile should be enabled only once it is ready to
|
||||||
|
* be used. Only the profile owner can call this.
|
||||||
|
*
|
||||||
|
* @see #isPRofileOwnerApp
|
||||||
|
*
|
||||||
|
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
|
||||||
|
*/
|
||||||
|
public void setProfileEnabled(ComponentName admin) {
|
||||||
|
if (mService != null) {
|
||||||
|
try {
|
||||||
|
mService.setProfileEnabled(admin);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.w(TAG, "Failed talking with device policy service", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to determine if a particular package is registered as the Profile Owner for the
|
* Used to determine if a particular package is registered as the Profile Owner for the
|
||||||
* current user. A profile owner is a special device admin that has additional priviledges
|
* current user. A profile owner is a special device admin that has additional privileges
|
||||||
* within the managed profile.
|
* within the managed profile.
|
||||||
*
|
*
|
||||||
* @param packageName The package name of the app to compare with the registered profile owner.
|
* @param packageName The package name of the app to compare with the registered profile owner.
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ interface IDevicePolicyManager {
|
|||||||
boolean setProfileOwner(String packageName, String ownerName, int userHandle);
|
boolean setProfileOwner(String packageName, String ownerName, int userHandle);
|
||||||
String getProfileOwner(int userHandle);
|
String getProfileOwner(int userHandle);
|
||||||
String getProfileOwnerName(int userHandle);
|
String getProfileOwnerName(int userHandle);
|
||||||
|
void setProfileEnabled(in ComponentName who);
|
||||||
|
|
||||||
boolean installCaCert(in byte[] certBuffer);
|
boolean installCaCert(in byte[] certBuffer);
|
||||||
void uninstallCaCert(in byte[] certBuffer);
|
void uninstallCaCert(in byte[] certBuffer);
|
||||||
|
|||||||
@@ -2887,6 +2887,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
|
@Override
|
||||||
public String getProfileOwner(int userHandle) {
|
public String getProfileOwner(int userHandle) {
|
||||||
if (!mHasFeature) {
|
if (!mHasFeature) {
|
||||||
|
|||||||
Reference in New Issue
Block a user