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

Commit c0d07059 authored by Ethan Chen's avatar Ethan Chen Committed by Sam Mortimer
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 b38dfe53
Loading
Loading
Loading
Loading
+17 −13
Original line number Original line Diff line number Diff line
@@ -7102,6 +7102,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
        }
        enforceFullCrossUsersPermission(userHandle);
        enforceFullCrossUsersPermission(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) {
            // It's not critical here, but let's make sure the package name is correct, in case
            // It's not critical here, but let's make sure the package name is correct, in case
            // we start using it for different purposes.
            // we start using it for different purposes.
            ensureCallerPackage(callerPackage);
            ensureCallerPackage(callerPackage);
@@ -7113,10 +7117,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                throw new SecurityException(e);
                throw new SecurityException(e);
            }
            }
        boolean legacyApp = false;
            if (ai.targetSdkVersion <= Build.VERSION_CODES.M) {
            if (ai.targetSdkVersion <= Build.VERSION_CODES.M) {
                legacyApp = true;
                legacyApp = true;
            }
            }
        }
        final int rawStatus = getEncryptionStatus();
        final int rawStatus = getEncryptionStatus();
        if ((rawStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE_PER_USER) && legacyApp) {
        if ((rawStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE_PER_USER) && legacyApp) {