Lockdown DPMS.getOrganizationNameForUser()
Only allow system components to call this hidden API. Bug: 192368508 Test: atest FrameworksServicesTests:DevicePolicyManagerTest Change-Id: I740943195f016b30607d4103a54ca0fe04d31f8a
This commit is contained in:
@@ -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