diff options
| author | 2016-02-15 10:47:40 +0000 | |
|---|---|---|
| committer | 2016-02-15 10:47:41 +0000 | |
| commit | eff90bd5ff6bd50325149a5010183277bd76f4c6 (patch) | |
| tree | 17d5c10f65e492d06c66479d5ee590bfef183f18 | |
| parent | 3e425f6c4be3fc30695473329c6364abfe69a059 (diff) | |
| parent | 8f7698aaf630787693ec7edb4779a27fdd2b888b (diff) | |
Merge "Allow privileged apps to set the organization color." into nyc-dev
3 files changed, 37 insertions, 0 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index f53170a77220..d26e4292e1b3 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -16,12 +16,14 @@ package android.app.admin; +import android.annotation.ColorInt; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; +import android.annotation.UserIdInt; import android.app.Activity; import android.auditing.SecurityLog; import android.auditing.SecurityLog.SecurityEvent; @@ -5612,6 +5614,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. * This color is used as background color of the confirm credentials screen for that user. * diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index bd6818264448..685ec3e08415 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -277,6 +277,7 @@ interface IDevicePolicyManager { boolean isSeparateProfileChallengeAllowed(int userHandle); void setOrganizationColor(in ComponentName admin, in int color); + void setOrganizationColorForUser(in int color, in int userId); int getOrganizationColor(in ComponentName admin); int getOrganizationColorForUser(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 916b66d04a54..cda60bd3839a 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -8325,6 +8325,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 public int getOrganizationColor(@NonNull ComponentName who) { if (!mHasFeature) { return ActiveAdmin.DEF_ORGANIZATION_COLOR; |