Added restriction if a user is allowed to change the icon.
BUG: 25305966 Change-Id: I3d527224f00087b2bd959879ebb143e2ecb9c914
This commit is contained in:
@@ -28558,6 +28558,7 @@ package android.os {
|
||||
field public static final java.lang.String DISALLOW_OUTGOING_CALLS = "no_outgoing_calls";
|
||||
field public static final java.lang.String DISALLOW_REMOVE_USER = "no_remove_user";
|
||||
field public static final java.lang.String DISALLOW_SAFE_BOOT = "no_safe_boot";
|
||||
field public static final java.lang.String DISALLOW_SET_USER_ICON = "no_set_user_icon";
|
||||
field public static final java.lang.String DISALLOW_SHARE_LOCATION = "no_share_location";
|
||||
field public static final java.lang.String DISALLOW_SMS = "no_sms";
|
||||
field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps";
|
||||
|
||||
@@ -30576,6 +30576,7 @@ package android.os {
|
||||
field public static final java.lang.String DISALLOW_OUTGOING_CALLS = "no_outgoing_calls";
|
||||
field public static final java.lang.String DISALLOW_REMOVE_USER = "no_remove_user";
|
||||
field public static final java.lang.String DISALLOW_SAFE_BOOT = "no_safe_boot";
|
||||
field public static final java.lang.String DISALLOW_SET_USER_ICON = "no_set_user_icon";
|
||||
field public static final java.lang.String DISALLOW_SHARE_LOCATION = "no_share_location";
|
||||
field public static final java.lang.String DISALLOW_SMS = "no_sms";
|
||||
field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps";
|
||||
|
||||
@@ -28567,6 +28567,7 @@ package android.os {
|
||||
field public static final java.lang.String DISALLOW_OUTGOING_CALLS = "no_outgoing_calls";
|
||||
field public static final java.lang.String DISALLOW_REMOVE_USER = "no_remove_user";
|
||||
field public static final java.lang.String DISALLOW_SAFE_BOOT = "no_safe_boot";
|
||||
field public static final java.lang.String DISALLOW_SET_USER_ICON = "no_set_user_icon";
|
||||
field public static final java.lang.String DISALLOW_SHARE_LOCATION = "no_share_location";
|
||||
field public static final java.lang.String DISALLOW_SMS = "no_sms";
|
||||
field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps";
|
||||
|
||||
@@ -528,6 +528,21 @@ public class UserManager {
|
||||
*/
|
||||
public static final String DISALLOW_DATA_ROAMING = "no_data_roaming";
|
||||
|
||||
/**
|
||||
* Specifies if a user is not allowed to change their icon. Device owner and profile owner
|
||||
* can set this restriction. When it is set by device owner, only the target user will be
|
||||
* affected. The default value is <code>false</code>.
|
||||
*
|
||||
* <p>Key for user restrictions.
|
||||
*
|
||||
* <p>Type: Boolean
|
||||
*
|
||||
* @see DevicePolicyManager#addUserRestriction(ComponentName, String)
|
||||
* @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
|
||||
* @see #getUserRestrictions()
|
||||
*/
|
||||
public static final String DISALLOW_SET_USER_ICON = "no_set_user_icon";
|
||||
|
||||
/**
|
||||
* Allows apps in the parent profile to handle web links from the managed profile.
|
||||
*
|
||||
|
||||
@@ -17,6 +17,7 @@ package android.os;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/**
|
||||
* @hide Only for use within the system server.
|
||||
@@ -81,4 +82,13 @@ public abstract class UserManagerInternal {
|
||||
* whether the user is managed by profile owner.
|
||||
*/
|
||||
public abstract void setUserManaged(int userId, boolean isManaged);
|
||||
|
||||
/**
|
||||
* Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService} to omit
|
||||
* restriction check, because DevicePolicyManager must always be able to set user icon
|
||||
* regardless of any restriction.
|
||||
* Also called by {@link com.android.server.pm.UserManagerService} because the logic of setting
|
||||
* the icon is in this method.
|
||||
*/
|
||||
public abstract void setUserIcon(int userId, Bitmap bitmap);
|
||||
}
|
||||
|
||||
@@ -729,23 +729,15 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
@Override
|
||||
public void setUserIcon(int userId, Bitmap bitmap) {
|
||||
checkManageUsersPermission("update users");
|
||||
long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mPackagesLock) {
|
||||
UserData userData = getUserDataNoChecks(userId);
|
||||
if (userData == null || userData.info.partial) {
|
||||
Slog.w(LOG_TAG, "setUserIcon: unknown user #" + userId);
|
||||
return;
|
||||
}
|
||||
writeBitmapLP(userData.info, bitmap);
|
||||
writeUserLP(userData);
|
||||
}
|
||||
sendUserInfoChangedBroadcast(userId);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
if (hasUserRestriction(UserManager.DISALLOW_SET_USER_ICON, userId)) {
|
||||
Log.w(LOG_TAG, "Cannot set user icon. DISALLOW_SET_USER_ICON is enabled.");
|
||||
return;
|
||||
}
|
||||
mLocalService.setUserIcon(userId, bitmap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void sendUserInfoChangedBroadcast(int userId) {
|
||||
Intent changedIntent = new Intent(Intent.ACTION_USER_INFO_CHANGED);
|
||||
changedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
|
||||
@@ -2894,6 +2886,25 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
mIsUserManaged.put(userId, isManaged);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserIcon(int userId, Bitmap bitmap) {
|
||||
long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mPackagesLock) {
|
||||
UserData userData = getUserDataNoChecks(userId);
|
||||
if (userData == null || userData.info.partial) {
|
||||
Slog.w(LOG_TAG, "setUserIcon: unknown user #" + userId);
|
||||
return;
|
||||
}
|
||||
writeBitmapLP(userData.info, bitmap);
|
||||
writeUserLP(userData);
|
||||
}
|
||||
sendUserInfoChangedBroadcast(userId);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class Shell extends ShellCommand {
|
||||
|
||||
@@ -92,7 +92,8 @@ public class UserRestrictionsUtils {
|
||||
UserManager.DISALLOW_RECORD_AUDIO,
|
||||
UserManager.DISALLOW_CAMERA,
|
||||
UserManager.DISALLOW_RUN_IN_BACKGROUND,
|
||||
UserManager.DISALLOW_DATA_ROAMING
|
||||
UserManager.DISALLOW_DATA_ROAMING,
|
||||
UserManager.DISALLOW_SET_USER_ICON
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -7028,7 +7028,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
||||
int userId = UserHandle.getCallingUserId();
|
||||
long id = mInjector.binderClearCallingIdentity();
|
||||
try {
|
||||
mUserManager.setUserIcon(userId, icon);
|
||||
mUserManagerInternal.setUserIcon(userId, icon);
|
||||
} finally {
|
||||
mInjector.binderRestoreCallingIdentity(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user