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

Unverified Commit 1024ad16 authored by Ethan Chen's avatar Ethan Chen Committed by Michael Bestas
Browse files

Check for null callerPackage in getStorageEncryptionStatus

* This function assumes that callerPackage is always valid,
  even though the parameter is annotated nullable. Check
  and assume the function was called by the system if the
  callerPackage was null.

Change-Id: Ie936d401f666ac8022635fb49d9ab2adfb5916c4
parent 610c2585
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -9010,7 +9010,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        final CallerIdentity caller = getCallerIdentity(callerPackage);
        Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
        boolean legacyApp = false;
        // callerPackage can only be null if we were called from within the system,
        // which means that we are not a legacy app.
        if (callerPackage != null) {
            final ApplicationInfo ai;
            try {
                ai = mIPackageManager.getApplicationInfo(callerPackage, 0, userHandle);
@@ -9018,10 +9021,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                throw new SecurityException(e);
            }
        boolean legacyApp = false;
            if (ai.targetSdkVersion <= Build.VERSION_CODES.M) {
                legacyApp = true;
            }
        }
        final int rawStatus = getEncryptionStatus();
        if ((rawStatus == ENCRYPTION_STATUS_ACTIVE_PER_USER) && legacyApp) {