Merge "Lockdown DPMS.getOrganizationNameForUser()" into sc-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e9226e8f46
@@ -14060,6 +14060,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