From 9f5960c8dcda6ed5d66c06183bad44564282332d Mon Sep 17 00:00:00 2001 From: Tim Schneeberger Date: Sun, 22 Dec 2024 15:44:32 +0100 Subject: [PATCH] fix: remove nested try/catch --- .../hiddenapi_impl/ShizukuSystemServerApi.java | 7 ++++--- .../main/java/android/permission/IPermissionManager.java | 6 ------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/hidden-api-impl/src/main/java/me/timschneeberger/hiddenapi_impl/ShizukuSystemServerApi.java b/hidden-api-impl/src/main/java/me/timschneeberger/hiddenapi_impl/ShizukuSystemServerApi.java index 61924211c..fc834ef59 100644 --- a/hidden-api-impl/src/main/java/me/timschneeberger/hiddenapi_impl/ShizukuSystemServerApi.java +++ b/hidden-api-impl/src/main/java/me/timschneeberger/hiddenapi_impl/ShizukuSystemServerApi.java @@ -54,10 +54,11 @@ public static void PermissionManager_grantRuntimePermission(String packageName, else if (Build.VERSION.SDK_INT == 34) { try { PERMISSION_MANAGER.getOrThrow().grantRuntimePermission(packageName, permissionName, 0, userId); + return; } - catch (NoSuchMethodError e) { - PERMISSION_MANAGER.getOrThrow().grantRuntimePermission(packageName, permissionName, userId); - } + catch (NoSuchMethodError ignored) {} + // Retry with old method + PERMISSION_MANAGER.getOrThrow().grantRuntimePermission(packageName, permissionName, userId); } else { PERMISSION_MANAGER.getOrThrow().grantRuntimePermission(packageName, permissionName, userId); } diff --git a/hidden-api-stubs/src/main/java/android/permission/IPermissionManager.java b/hidden-api-stubs/src/main/java/android/permission/IPermissionManager.java index ccf369bde..65eaa8a21 100644 --- a/hidden-api-stubs/src/main/java/android/permission/IPermissionManager.java +++ b/hidden-api-stubs/src/main/java/android/permission/IPermissionManager.java @@ -19,12 +19,6 @@ void grantRuntimePermission(String packageName, String permissionName, int devic void grantRuntimePermission(String packageName, String permissionName, String deviceId, int userId) throws RemoteException; - void revokeRuntimePermission(String packageName, String permissionName, int userId, - String reason) throws RemoteException; - - void revokeRuntimePermission(String packageName, String permissionName, int deviceId, int userId, String reason) - throws RemoteException; - abstract class Stub extends Binder implements IPermissionManager { public static IPermissionManager asInterface(IBinder obj) {