Provide api to set the managed profile name.
Instead of sending the profile name in the provisioning intent
the mdm should set the profile name after provisioning has completed.
This allows us to simplify the provisioning flow and the mdm can
change the name of the profile later on if required.
Change-Id: I821ef2300eae74e89872152ae1c89ac3ecbb82e7
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 4351f9d..9ed298e 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -1922,6 +1922,26 @@
}
/**
+ * Sets the name of the Managed profile. In the device owner case it sets the name of the user
+ * which it is called from. Only the profile owner or device owner can call this. If this is
+ * never called by the profile or device owner, the name will be set to default values.
+ *
+ * @see #isProfileOwnerApp
+ * @see #isDeviceOwnerApp
+ *
+ * @param profileName The name of the profile.
+ */
+ public void setProfileName(ComponentName who, String profileName) {
+ if (mService != null) {
+ try {
+ mService.setProfileName(who, profileName);
+ } 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
* current user. A profile owner is a special device admin that has additional privileges
* within the managed profile.