2

I am trying to hook into this method in NotificationManagerService using Xposed:

void enqueueNotificationInternal(final String pkg, final String opPkg, final int callingUid,
            final int callingPid, final String tag, final int id, final Notification notification,
            int[] idOut, int incomingUserId)

For that I am using this hook:

XposedHelpers.findAndHookMethod("com.android.server.notification.NotificationManagerService", loadPackageParam.classLoader,
                "enqueueNotificationInternal", String.class, String.class, Integer.class, Integer.class, String.class,
                Integer.class, Notification.class, Integer.class, Integer.class, new XC_MethodHook(){
//More code...
});

However this is giving me an error in the Xposed log that the method could not be found. It is probably because of int[] idOut, because I am not sure what the class of that 'type' of that parameter is. Apparently not Integer.class, or is it and is something else wrong?

Wilco
  • 53
  • 1
  • 6
  • It appears you are trying to match "final int callingUid" to Integer.class, which is not correct. You can user Integer.TYPE or int.class for int primitives. – Jamie Nov 17 '15 at 22:04
  • For idOut, you can do: Class.forName("[I") or you could do "new int[0].getClass()" – Jamie Nov 17 '15 at 22:08
  • OK, thanks. I'll try it out after school :) – Wilco Nov 18 '15 at 07:50
  • Thanks, it works now! I replaced Integer.class with int.class, and the integer array with new int[0].class – Wilco Nov 19 '15 at 15:58

3 Answers3

3

What worked for me was declaring an empty array variable and get its class:

int[] data = new int[0];

XposedHelpers.findAndHookMethod("com.class", 
    loadPackageParam.classLoader, 
    "methodName", 
    String.class, 
    data.getClass(), 
    new XC_MethodHook(){
        // code
    });

Another possible answer:

XposedHelpers.findAndHookMethod("com.class", 
    loadPackageParam.classLoader, 
    "methodName", 
    String.class, 
    int[].class, 
    new XC_MethodHook(){
        // code
    });
Marlon
  • 1,839
  • 2
  • 19
  • 42
1

This works:

XposedHelpers.findAndHookMethod("com.android.server.notification.NotificationManagerService", 
    loadPackageParam.classLoader, "enqueueNotificationInternal", String.class, 
    String.class, int.class, int.class, String.class, int.class,
    Notification.class, new int[0].class, int.class, new XC_MethodHook(){
        //More code...
    });
Robert
  • 39,162
  • 17
  • 99
  • 152
Wilco
  • 53
  • 1
  • 6
1

You can simply use:

 int[].class

other answers works but are the wrong way.

Simone Aonzo
  • 841
  • 10
  • 21