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

Commit a55fc992 authored by Jessica Hummel's avatar Jessica Hummel Committed by Android (Google) Code Review
Browse files

Merge "Provide api to set the managed profile name."

parents 420b9f40 1333ea1e
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
@@ -2103,6 +2103,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) {