'How to hook into a method with int[] using xposed?
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?
Solution 1:[1]
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
});
Solution 2:[2]
You can simply use:
int[].class
other answers works but are the wrong way.
Solution 3:[3]
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...
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Simone Aonzo |
Solution 3 | Robert |