Merge "API polish in DPM for organization color and name methods" into nyc-dev
diff --git a/api/current.txt b/api/current.txt
index eb129da..8d1b450 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -5901,7 +5901,7 @@
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 @@
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);
diff --git a/api/system-current.txt b/api/system-current.txt
index 5bfbc16..b3bac02 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6044,7 +6044,7 @@
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 @@
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);
diff --git a/api/test-current.txt b/api/test-current.txt
index 04fedb1..fcfe489 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -5905,7 +5905,7 @@
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 @@
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);
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 96757bb..a7bb348 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -6050,11 +6050,13 @@
* {@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 @@
*
* 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 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 @@
* 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 @@
* 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 @@
* @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 @@
* @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 @@
*
* @hide
*/
- public String getOrganizationNameForUser(int userHandle) {
+ public CharSequence getOrganizationNameForUser(int userHandle) {
try {
return mService.getOrganizationNameForUser(userHandle);
} catch (RemoteException re) {
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 6df1038..2801b87 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -284,9 +284,9 @@
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);
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 72e8bd3..0454b00 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -8660,7 +8660,7 @@
}
@Override
- public void setOrganizationName(@NonNull ComponentName who, String text) {
+ public void setOrganizationName(@NonNull ComponentName who, CharSequence text) {
if (!mHasFeature) {
return;
}
@@ -8671,14 +8671,15 @@
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
if (!TextUtils.equals(admin.organizationName, text)) {
- admin.organizationName = TextUtils.nullIfEmpty(text);
+ admin.organizationName = (text == null || text.length() == 0)
+ ? null : text.toString();
saveSettingsLocked(userHandle);
}
}
}
@Override
- public String getOrganizationName(@NonNull ComponentName who) {
+ public CharSequence getOrganizationName(@NonNull ComponentName who) {
if (!mHasFeature) {
return null;
}
@@ -8692,7 +8693,7 @@
}
@Override
- public String getOrganizationNameForUser(int userHandle) {
+ public CharSequence getOrganizationNameForUser(int userHandle) {
if (!mHasFeature) {
return null;
}