Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1333ea1e authored by Jessica Hummel's avatar Jessica Hummel
Browse files

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
parent 1422c5f6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5304,6 +5304,7 @@ package android.app.admin {
    method public void setPasswordMinimumUpperCase(android.content.ComponentName, int);
    method public void setPasswordQuality(android.content.ComponentName, int);
    method public void setProfileEnabled(android.content.ComponentName);
    method public void setProfileName(android.content.ComponentName, java.lang.String);
    method public void setRecommendedGlobalProxy(android.content.ComponentName, android.net.ProxyInfo);
    method public void setRestrictionsProvider(android.content.ComponentName, android.content.ComponentName);
    method public void setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String);
+20 −0
Original line number Diff line number Diff line
@@ -1921,6 +1921,26 @@ public class DevicePolicyManager {
        }
    }

    /**
     * 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
+1 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ interface IDevicePolicyManager {
    String getProfileOwner(int userHandle);
    String getProfileOwnerName(int userHandle);
    void setProfileEnabled(in ComponentName who);
    void setProfileName(in ComponentName who, String profileName);

    boolean installCaCert(in ComponentName admin, in byte[] certBuffer);
    void uninstallCaCert(in ComponentName admin, in String alias);
+19 −1
Original line number Diff line number Diff line
@@ -3222,7 +3222,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            // Check if this is the profile owner who is calling
            getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
            int userId = UserHandle.getCallingUserId();
            Slog.d(LOG_TAG, "Enabling the profile for: " + userId);

            long id = Binder.clearCallingIdentity();
            try {
@@ -3239,6 +3238,25 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
    }

    @Override
    public void setProfileName(ComponentName who, String profileName) {
        int userId = UserHandle.getCallingUserId();

        if (who == null) {
            throw new NullPointerException("ComponentName is null");
        }

        // Check if this is the profile owner (includes device owner).
        getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);

        long id = Binder.clearCallingIdentity();
        try {
            mUserManager.setUserName(userId, profileName);
        } finally {
            restoreCallingIdentity(id);
        }
    }

    @Override
    public String getProfileOwner(int userHandle) {
        if (!mHasFeature) {