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

Commit b08003b9 authored by Sooraj Sasindran's avatar Sooraj Sasindran Committed by Automerger Merge Worker
Browse files

Merge "Send same exception in case of installed package" into sc-v2-dev am:...

Merge "Send same exception in case of installed package" into sc-v2-dev am: 7efbb60d am: fb3a6f3b

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

Change-Id: I6f9f0425281689f7b24a6337d7bd910f82b11951
parents f0a30f66 fb3a6f3b
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -308,6 +308,12 @@ public final class TelephonyPermissions {
        return checkPrivilegedReadPermissionOrCarrierPrivilegePermission(
                context, subId, callingPackage, callingFeatureId, message, false, reportFailure);
    }

    private static void throwSecurityExceptionAsUidDoesNotHaveAccess(String message, int uid) {
        throw new SecurityException(message + ": The uid " + uid
                + " does not meet the requirements to access device identifiers.");
    }

    /**
     * Checks whether the app with the given pid/uid can read device identifiers.
     *
@@ -343,10 +349,15 @@ public final class TelephonyPermissions {

        LegacyPermissionManager permissionManager = (LegacyPermissionManager)
                context.getSystemService(Context.LEGACY_PERMISSION_SERVICE);
        if (permissionManager.checkDeviceIdentifierAccess(callingPackage, message, callingFeatureId,
        try {
            if (permissionManager.checkDeviceIdentifierAccess(callingPackage, message,
                    callingFeatureId,
                    pid, uid) == PackageManager.PERMISSION_GRANTED) {
                return true;
            }
        } catch (SecurityException se) {
            throwSecurityExceptionAsUidDoesNotHaveAccess(message, uid);
        }

        if (reportFailure) {
            return reportAccessDeniedToReadIdentifiers(context, subId, pid, uid, callingPackage,
@@ -410,8 +421,8 @@ public final class TelephonyPermissions {
                return false;
            }
        }
        throw new SecurityException(message + ": The user " + uid
                + " does not meet the requirements to access device identifiers.");
        throwSecurityExceptionAsUidDoesNotHaveAccess(message, uid);
        return true;
    }

    /**