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

Commit 4e8bbd23 authored by Nicolas Prévot's avatar Nicolas Prévot Committed by android-build-merger
Browse files

Merge "Allow privileged apps to set the organization color." into nyc-dev am: eff90bd5

am: 2da7b6eb

* commit '2da7b6eb':
  Allow privileged apps to set the organization color.
parents bf43eac0 2da7b6eb
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -16,12 +16,14 @@


package android.app.admin;
package android.app.admin;


import android.annotation.ColorInt;
import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.annotation.SystemApi;
import android.annotation.UserIdInt;
import android.app.Activity;
import android.app.Activity;
import android.auditing.SecurityLog;
import android.auditing.SecurityLog;
import android.auditing.SecurityLog.SecurityEvent;
import android.auditing.SecurityLog.SecurityEvent;
@@ -5611,6 +5613,25 @@ public class DevicePolicyManager {
        }
        }
    }
    }


    /**
     * @hide
     *
     * Sets the color used for customization.
     *
     * @param color The 32bit representation of the color to be used.
     * @param userId which user to set the color to.
     * @RequiresPermission(allOf = {
     *       Manifest.permission.MANAGE_USERS,
     *       Manifest.permission.INTERACT_ACROSS_USERS_FULL})
     */
    public void setOrganizationColorForUser(@ColorInt int color, @UserIdInt int userId) {
        try {
            mService.setOrganizationColorForUser(color, userId);
        } catch (RemoteException re) {
            Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
        }
    }

    /**
    /**
     * Called by a profile owner of a managed profile to retrieve the color used for customization.
     * Called by a profile owner of a managed profile to retrieve the color used for customization.
     * This color is used as background color of the confirm credentials screen for that user.
     * This color is used as background color of the confirm credentials screen for that user.
+1 −0
Original line number Original line Diff line number Diff line
@@ -277,6 +277,7 @@ interface IDevicePolicyManager {
    boolean isSeparateProfileChallengeAllowed(int userHandle);
    boolean isSeparateProfileChallengeAllowed(int userHandle);


    void setOrganizationColor(in ComponentName admin, in int color);
    void setOrganizationColor(in ComponentName admin, in int color);
    void setOrganizationColorForUser(in int color, in int userId);
    int getOrganizationColor(in ComponentName admin);
    int getOrganizationColor(in ComponentName admin);
    int getOrganizationColorForUser(int userHandle);
    int getOrganizationColorForUser(int userHandle);


+15 −0
Original line number Original line Diff line number Diff line
@@ -8324,6 +8324,21 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
        }
    }
    }


    @Override
    public void setOrganizationColorForUser(int color, int userId) {
        if (!mHasFeature) {
            return;
        }
        enforceFullCrossUsersPermission(userId);
        enforceManageUsers();
        enforceManagedProfile(userId, "set organization color");
        synchronized (this) {
            ActiveAdmin admin = getProfileOwnerAdminLocked(userId);
            admin.organizationColor = color;
            saveSettingsLocked(userId);
        }
    }

    @Override
    @Override
    public int getOrganizationColor(@NonNull ComponentName who) {
    public int getOrganizationColor(@NonNull ComponentName who) {
        if (!mHasFeature) {
        if (!mHasFeature) {