Merge "Proper fix for setDeviceOwner() permission check." into sc-v2-dev am: f70489f2d0 am: 5b905266dd

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15953790

Change-Id: I89c4e841cfc1e9116d7579ac30cb2215ccaecc2f
This commit is contained in:
TreeHugger Robot
2021-10-05 12:37:15 +00:00
committed by Automerger Merge Worker

View File

@@ -10630,19 +10630,21 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
}
final String adminPkg = admin.getPackageName();
try {
// Install the profile owner if not present.
if (!mIPackageManager.isPackageAvailable(adminPkg, userId)) {
mIPackageManager.installExistingPackageAsUser(adminPkg, userId,
PackageManager.INSTALL_ALL_WHITELIST_RESTRICTED_PERMISSIONS,
PackageManager.INSTALL_REASON_POLICY,
/* allowlistedRestrictedPermissions= */ null);
mInjector.binderWithCleanCallingIdentity(() -> {
try {
// Install the profile owner if not present.
if (!mIPackageManager.isPackageAvailable(adminPkg, userId)) {
mIPackageManager.installExistingPackageAsUser(adminPkg, userId,
PackageManager.INSTALL_ALL_WHITELIST_RESTRICTED_PERMISSIONS,
PackageManager.INSTALL_REASON_POLICY,
/* allowlistedRestrictedPermissions= */ null);
}
} catch (RemoteException e) {
// Does not happen, same process
Slogf.wtf(LOG_TAG, e, "Failed to install admin package %s for user %d",
adminPkg, userId);
}
} catch (RemoteException e) {
// Does not happen, same process
Slogf.wtf(LOG_TAG, e, "Failed to install admin package %s for user %d",
adminPkg, userId);
}
});
// Set admin.
setActiveAdmin(profileOwner, /* refreshing= */ true, userId);