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

Commit ce8890d4 authored by Meng Wang's avatar Meng Wang Committed by Android (Google) Code Review
Browse files

Merge "Allow platform app to use USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER permission"

parents 15449e96 9990ecec
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -405,6 +405,10 @@ public final class TelephonyPermissions {
     */
    public static boolean checkCallingOrSelfUseIccAuthWithDeviceIdentifier(Context context,
            String callingPackage, String callingFeatureId, String message) {
        // The implementation follows PermissionChecker.checkAppOpPermission, but it cannot be
        // used directly: because it uses noteProxyOpNoThrow which requires the phone process
        // having the permission, which doesn't make sense since phone process is the ower of
        // data/action.
        // Cannot perform appop check if the calling package is null
        if (callingPackage == null) {
            return false;
@@ -413,7 +417,17 @@ public final class TelephonyPermissions {
        AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
        int opMode = appOps.noteOpNoThrow(AppOpsManager.OPSTR_USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER,
                callingUid, callingPackage, callingFeatureId, message);
        return opMode == AppOpsManager.MODE_ALLOWED;
        switch (opMode) {
            case AppOpsManager.MODE_ALLOWED:
            case AppOpsManager.MODE_FOREGROUND:
                return true;
            case AppOpsManager.MODE_DEFAULT:
                return context.checkCallingOrSelfPermission(
                            Manifest.permission.USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER)
                        == PERMISSION_GRANTED;
            default:
                return false;
        }
    }

    /**