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

Commit 74cd7307 authored by Michal Karpinski's avatar Michal Karpinski
Browse files

API polish in DPM for organization color and name methods

- Returning and accepting CharSequence instead of String
- Enforcing 100% opacity and adjusting javadocs for color
format
- Adding @ColorInt annotations

Bug: 27531295
Change-Id: Id27d4fd5e7bb4d746cc61288457eb4eb86224505
parent 73c9391d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5901,7 +5901,7 @@ package android.app.admin {
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
    method public long getMaximumTimeToLock(android.content.ComponentName);
    method public int getOrganizationColor(android.content.ComponentName);
    method public java.lang.String getOrganizationName(android.content.ComponentName);
    method public java.lang.CharSequence getOrganizationName(android.content.ComponentName);
    method public android.app.admin.DevicePolicyManager getParentProfileInstance(android.content.ComponentName);
    method public long getPasswordExpiration(android.content.ComponentName);
    method public long getPasswordExpirationTimeout(android.content.ComponentName);
@@ -5976,7 +5976,7 @@ package android.app.admin {
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
    method public void setMaximumTimeToLock(android.content.ComponentName, long);
    method public void setOrganizationColor(android.content.ComponentName, int);
    method public void setOrganizationName(android.content.ComponentName, java.lang.String);
    method public void setOrganizationName(android.content.ComponentName, java.lang.CharSequence);
    method public java.lang.String[] setPackagesSuspended(android.content.ComponentName, java.lang.String[], boolean);
    method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
    method public void setPasswordHistoryLength(android.content.ComponentName, int);
+2 −2
Original line number Diff line number Diff line
@@ -6044,7 +6044,7 @@ package android.app.admin {
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
    method public long getMaximumTimeToLock(android.content.ComponentName);
    method public int getOrganizationColor(android.content.ComponentName);
    method public java.lang.String getOrganizationName(android.content.ComponentName);
    method public java.lang.CharSequence getOrganizationName(android.content.ComponentName);
    method public android.app.admin.DevicePolicyManager getParentProfileInstance(android.content.ComponentName);
    method public long getPasswordExpiration(android.content.ComponentName);
    method public long getPasswordExpirationTimeout(android.content.ComponentName);
@@ -6126,7 +6126,7 @@ package android.app.admin {
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
    method public void setMaximumTimeToLock(android.content.ComponentName, long);
    method public void setOrganizationColor(android.content.ComponentName, int);
    method public void setOrganizationName(android.content.ComponentName, java.lang.String);
    method public void setOrganizationName(android.content.ComponentName, java.lang.CharSequence);
    method public java.lang.String[] setPackagesSuspended(android.content.ComponentName, java.lang.String[], boolean);
    method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
    method public void setPasswordHistoryLength(android.content.ComponentName, int);
+2 −2
Original line number Diff line number Diff line
@@ -5905,7 +5905,7 @@ package android.app.admin {
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
    method public long getMaximumTimeToLock(android.content.ComponentName);
    method public int getOrganizationColor(android.content.ComponentName);
    method public java.lang.String getOrganizationName(android.content.ComponentName);
    method public java.lang.CharSequence getOrganizationName(android.content.ComponentName);
    method public android.app.admin.DevicePolicyManager getParentProfileInstance(android.content.ComponentName);
    method public long getPasswordExpiration(android.content.ComponentName);
    method public long getPasswordExpirationTimeout(android.content.ComponentName);
@@ -5980,7 +5980,7 @@ package android.app.admin {
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
    method public void setMaximumTimeToLock(android.content.ComponentName, long);
    method public void setOrganizationColor(android.content.ComponentName, int);
    method public void setOrganizationName(android.content.ComponentName, java.lang.String);
    method public void setOrganizationName(android.content.ComponentName, java.lang.CharSequence);
    method public java.lang.String[] setPackagesSuspended(android.content.ComponentName, java.lang.String[], boolean);
    method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
    method public void setPasswordHistoryLength(android.content.ComponentName, int);
+13 −9
Original line number Diff line number Diff line
@@ -6050,11 +6050,13 @@ public class DevicePolicyManager {
     * {@link android.app.KeyguardManager#createConfirmDeviceCredentialIntent}.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param color The 32bit representation of the color to be used.
     * @param color The 24bit (0xRRGGBB) representation of the color to be used.
     * @throws SecurityException if {@code admin} is not a profile owner.
     */
    public void setOrganizationColor(@NonNull ComponentName admin, int color) {
        try {
            // always enforce alpha channel to have 100% opacity
            color |= 0xFF000000;
            mService.setOrganizationColor(admin, color);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
@@ -6066,7 +6068,7 @@ public class DevicePolicyManager {
     *
     * Sets the color used for customization.
     *
     * @param color The 32bit representation of the color to be used.
     * @param color The 24bit (0xRRGGBB) representation of the color to be used.
     * @param userId which user to set the color to.
     * @RequiresPermission(allOf = {
     *       Manifest.permission.MANAGE_USERS,
@@ -6074,6 +6076,8 @@ public class DevicePolicyManager {
     */
    public void setOrganizationColorForUser(@ColorInt int color, @UserIdInt int userId) {
        try {
            // always enforce alpha channel to have 100% opacity
            color |= 0xFF000000;
            mService.setOrganizationColorForUser(color, userId);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
@@ -6085,10 +6089,10 @@ public class DevicePolicyManager {
     * This color is used as background color of the confirm credentials screen for that user.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @return The 32bit representation of the color to be used.
     * @return The 24bit (0xRRGGBB) representation of the color to be used.
     * @throws SecurityException if {@code admin} is not a profile owner.
     */
    public int getOrganizationColor(@NonNull ComponentName admin) {
    public @ColorInt int getOrganizationColor(@NonNull ComponentName admin) {
        try {
            return mService.getOrganizationColor(admin);
        } catch (RemoteException re) {
@@ -6101,9 +6105,9 @@ public class DevicePolicyManager {
     * Retrieve the customization color for a given user.
     *
     * @param userHandle The user id of the user we're interested in.
     * @return The 32bit representation of the color to be used.
     * @return The 24bit (0xRRGGBB) representation of the color to be used.
     */
    public int getOrganizationColorForUser(int userHandle) {
    public @ColorInt int getOrganizationColorForUser(int userHandle) {
        try {
            return mService.getOrganizationColorForUser(userHandle);
        } catch (RemoteException re) {
@@ -6123,7 +6127,7 @@ public class DevicePolicyManager {
     * @param title The organization name or {@code null} to clear a previously set name.
     * @throws SecurityException if {@code admin} is not a profile owner.
     */
    public void setOrganizationName(@NonNull ComponentName admin, @Nullable String title) {
    public void setOrganizationName(@NonNull ComponentName admin, @Nullable CharSequence title) {
        try {
            mService.setOrganizationName(admin, title);
        } catch (RemoteException re) {
@@ -6139,7 +6143,7 @@ public class DevicePolicyManager {
     * @return The organization name or {@code null} if none is set.
     * @throws SecurityException if {@code admin} is not a profile owner.
     */
    public String getOrganizationName(@NonNull ComponentName admin) {
    public CharSequence getOrganizationName(@NonNull ComponentName admin) {
        try {
            return mService.getOrganizationName(admin);
        } catch (RemoteException re) {
@@ -6155,7 +6159,7 @@ public class DevicePolicyManager {
     *
     * @hide
     */
    public String getOrganizationNameForUser(int userHandle) {
    public CharSequence getOrganizationNameForUser(int userHandle) {
        try {
            return mService.getOrganizationNameForUser(userHandle);
        } catch (RemoteException re) {
+3 −3
Original line number Diff line number Diff line
@@ -284,9 +284,9 @@ interface IDevicePolicyManager {
    int getOrganizationColor(in ComponentName admin);
    int getOrganizationColorForUser(int userHandle);

    void setOrganizationName(in ComponentName admin, in String title);
    String getOrganizationName(in ComponentName admin);
    String getOrganizationNameForUser(int userHandle);
    void setOrganizationName(in ComponentName admin, in CharSequence title);
    CharSequence getOrganizationName(in ComponentName admin);
    CharSequence getOrganizationNameForUser(int userHandle);

    int getUserProvisioningState();
    void setUserProvisioningState(int state, int userHandle);
Loading