import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.pm.UserInfo;
import android.graphics.Bitmap;
import android.net.ProxyInfo;
import android.net.Uri;
}
/**
+ * Called by the system to obtain a {@link DevicePolicyManager} whose calls act on the parent
+ * profile.
+ *
+ * @hide
+ */
+ public DevicePolicyManager getParentProfileInstance(UserInfo uInfo) {
+ mContext.checkSelfPermission(
+ android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
+ if (!uInfo.isManagedProfile()) {
+ throw new SecurityException("The user " + uInfo.id
+ + " does not have a parent profile.");
+ }
+ return new DevicePolicyManager(mContext, true);
+ }
+
+ /**
* Called by a profile owner of a managed profile to set the color used for customization.
* This color is used as background color of the confirm credentials screen for that user.
* The default color is {@link android.graphics.Color#GRAY}.
if (userInfo.isManagedProfile()) {
// If userInfo.id is a managed profile, we also need to look at
// the policies set on the parent.
- DevicePolicyManager parentDpm = dpm.getParentProfileInstance(admin);
+ DevicePolicyManager parentDpm = dpm.getParentProfileInstance(userInfo);
if ((parentDpm.getKeyguardDisabledFeatures(admin, userInfo.id)
& keyguardFeatures) != 0) {
if (enforcedAdmin == null) {
if (userInfo.isManagedProfile()) {
// If userInfo.id is a managed profile, we also need to look at
// the policies set on the parent.
- DevicePolicyManager parentDpm = dpm.getParentProfileInstance(admin);
+ DevicePolicyManager parentDpm = dpm.getParentProfileInstance(userInfo);
if (parentDpm.getMaximumTimeToLock(admin, userInfo.id) > 0) {
if (enforcedAdmin == null) {
enforcedAdmin = new EnforcedAdmin(admin, userInfo.id);