Skip to content

Commit

Permalink
fix: fixed crash on Android 14 in Shizuku setup
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Dec 16, 2023
1 parent 0665769 commit a2205b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.AppOpsManager;
import android.app.AppOpsManagerHidden;
import android.media.IAudioPolicyService;
import android.os.Build;
import android.os.IBinder;
import android.permission.IPermissionManager;
import android.os.RemoteException;
Expand Down Expand Up @@ -46,7 +47,15 @@ protected IAudioPolicyService create() {

public static void PermissionManager_grantRuntimePermission(String packageName, String permissionName, int userId) {
try {
PERMISSION_MANAGER.getOrThrow().grantRuntimePermission(packageName, permissionName, userId);
if (Build.VERSION.SDK_INT >= 34) {
try {
PERMISSION_MANAGER.getOrThrow().grantRuntimePermission(packageName, permissionName, 0, userId);
}catch (NoSuchMethodError e) {
PERMISSION_MANAGER.getOrThrow().grantRuntimePermission(packageName, permissionName, userId);
}
} else {
PERMISSION_MANAGER.getOrThrow().grantRuntimePermission(packageName, permissionName, userId);
}
}
catch(Exception ex) {
Log.e("ShizukuSystemServerApi", "Failed to call app ops service");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ public interface IPermissionManager extends IInterface {

void grantRuntimePermission(String packageName, String permissionName, int userId) throws RemoteException;

void grantRuntimePermission(String packageName, String permissionName, int 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) {
Expand Down

0 comments on commit a2205b3

Please sign in to comment.