Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 630dec9e authored by Tobias Thierer's avatar Tobias Thierer
Browse files

Fix DevicePolicyManager.isBackupServiceEnabled() breakage.

http://ag/12885739 introduced a enforceCallingPermission(BACKUP) check
but callers of this API do not hold that permission. This CL fixes
this by changing the check to enforceCallingOrSelfPermission(BACKUP),
and clearing the binder identity in DevicePolicyManagerService, which
makes the system server process the owner of that call.

Bug: 158482162
Bug: 172466964
Test: atest com.android.cts.devicepolicy.{Device,Profile}OwnerTest#testBackupServiceEnabling
Change-Id: I11d863229c4d62a058aaf37446a694b9c73ae5b8
parent ed6341bf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -512,7 +512,7 @@ public class BackupManagerService extends IBackupManager.Stub {
        int callingUid = Binder.getCallingUid();
        if (CompatChanges.isChangeEnabled(
                BackupManager.IS_BACKUP_SERVICE_ACTIVE_ENFORCE_PERMISSION_IN_SERVICE, callingUid)) {
            mContext.enforceCallingPermission(android.Manifest.permission.BACKUP,
            mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
                    "isBackupServiceActive");
        }
        synchronized (mStateLock) {
+9 −7
Original line number Diff line number Diff line
@@ -13478,6 +13478,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        final CallerIdentity caller = getCallerIdentity(admin);
        Preconditions.checkCallAuthorization(isDeviceOwner(caller) || isProfileOwner(caller));
        return mInjector.binderWithCleanCallingIdentity(() -> {
            synchronized (getLockObject()) {
                try {
                    IBackupManager ibm = mInjector.getIBackupManager();
@@ -13486,6 +13487,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                    throw new IllegalStateException("Failed requesting backup service state.", e);
                }
            }
        });
    }
    @Override