Merge "Lockdown DPMS.getOrganizationNameForUser()" into sc-qpr1-dev am: e9226e8f46
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15905687 Change-Id: I0739d826b5250deb9a35b0b44de45b106318ac06
This commit is contained in:
@@ -14061,6 +14061,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
|
||||
final CallerIdentity caller = getCallerIdentity();
|
||||
Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
|
||||
Preconditions.checkCallAuthorization(canManageUsers(caller));
|
||||
Preconditions.checkCallAuthorization(isManagedProfile(userHandle),
|
||||
"You can not get organization name outside a managed profile, userId = %d",
|
||||
userHandle);
|
||||
|
||||
@@ -7753,6 +7753,12 @@ public class DevicePolicyManagerTest extends DpmTestBase {
|
||||
DpmMockContext.CALLER_SYSTEM_USER_UID, admin1.getPackageName(), MODE_DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOrganizationNameForUser_calledByNonPrivilegedApp_throwsException() {
|
||||
assertExpectException(SecurityException.class, "Calling identity is not authorized",
|
||||
() -> dpm.getOrganizationNameForUser(UserHandle.USER_SYSTEM));
|
||||
}
|
||||
|
||||
private void setupVpnAuthorization(String userVpnPackage, int userVpnUid) {
|
||||
final AppOpsManager.PackageOps vpnOp = new AppOpsManager.PackageOps(userVpnPackage,
|
||||
userVpnUid, List.of(new AppOpsManager.OpEntry(
|
||||
|
||||
Reference in New Issue
Block a user