Merge "Add per-user version of DevicePolicyManager.getUserRestrictions."
This commit is contained in:
committed by
Android (Google) Code Review
commit
d7b43dd4bb
@@ -3788,12 +3788,18 @@ public class DevicePolicyManager {
|
||||
* {@link UserManager#getUserRestrictions()}.
|
||||
*
|
||||
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
|
||||
* @throws SecurityException if the {@code admin} is not an active admin.
|
||||
*/
|
||||
public Bundle getUserRestrictions(@NonNull ComponentName admin) {
|
||||
return getUserRestrictions(admin, myUserId());
|
||||
}
|
||||
|
||||
/** @hide per-user version */
|
||||
public Bundle getUserRestrictions(@NonNull ComponentName admin, int userHandle) {
|
||||
Bundle ret = null;
|
||||
if (mService != null) {
|
||||
try {
|
||||
ret = mService.getUserRestrictions(admin);
|
||||
ret = mService.getUserRestrictions(admin, userHandle);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed talking with device policy service", e);
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ interface IDevicePolicyManager {
|
||||
ComponentName getRestrictionsProvider(int userHandle);
|
||||
|
||||
void setUserRestriction(in ComponentName who, in String key, boolean enable);
|
||||
Bundle getUserRestrictions(in ComponentName who);
|
||||
Bundle getUserRestrictions(in ComponentName who, int userId);
|
||||
void addCrossProfileIntentFilter(in ComponentName admin, in IntentFilter filter, int flags);
|
||||
void clearCrossProfileIntentFilters(in ComponentName admin);
|
||||
|
||||
|
||||
@@ -5718,11 +5718,18 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle getUserRestrictions(ComponentName who) {
|
||||
public Bundle getUserRestrictions(ComponentName who, int userHandle) {
|
||||
Preconditions.checkNotNull(who, "ComponentName is null");
|
||||
enforceCrossUserPermission(userHandle);
|
||||
synchronized (this) {
|
||||
final ActiveAdmin activeAdmin =
|
||||
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
|
||||
ActiveAdmin activeAdmin = getActiveAdminUncheckedLocked(who, userHandle);
|
||||
if (activeAdmin == null) {
|
||||
throw new SecurityException("No active admin: " + activeAdmin);
|
||||
}
|
||||
if (activeAdmin.getUid() != mInjector.binderGetCallingUid()) {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS, null);
|
||||
}
|
||||
return activeAdmin.userRestrictions;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user