@PermissionResult
    public static int checkCallingPermission(@NonNull Context context,
                                             @NonNull String permission, @Nullable String packageName) {
        if (Binder.getCallingPid() == Process.myPid()) {
            return PERMISSION_DENIED;
        }
        return checkPermission(context, permission, Binder.getCallingPid(),
                Binder.getCallingUid(), packageName);
    }
Checks whether the IPC you are handling has a given permission and whether
the app op that corresponds to this permission is allowed.

@param context     Context for accessing resources.
@param permission  The permission to check.
@param packageName The package name making the IPC. If null the
                   the first package for the calling UID will be used.
@return The permission check result which is either {@link #PERMISSION_GRANTED}
or {@link #PERMISSION_DENIED} or {@link #PERMISSION_DENIED_APP_OP}.
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/compat/PermissionChecker.java