Add a DPM method to allow system to query parent profile instance.
Bug: 26830384
Change-Id: Ib12b171b1032bd86488f32f8d22eb0a9efb75e8f
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index a3c615d..e4e97a1 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -30,6 +30,7 @@
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;
@@ -5346,6 +5347,22 @@
}
/**
+ * 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}.