Pushbullet Universal Copy/Paste Availabe for Linux, Mac OS X

Pushbullet is one of those useful utilities that once installed, permanently … more

Enable the Hidden Notification LED on the Google Nexus 6!

LED notification lights have existed on Android devices since the very beginnings … more

MX Player Ready to Rock on Lollipop

A good video player should be reliable and free. One of the XDA Community Apps, MX Player, meets both of … more

How to Disable Data Encryption on Nexus 6

In late September, Google decided to step on NSA’s toes and turn on encryption by default in … more

Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

How to use hidden class in hook?

OP pyler

19th June 2014, 08:18 PM   |  #1  
OP Senior Member
Thanks Meter: 569
 
473 posts
Join Date:Joined: Jan 2013
More
I have something like this..
Code:
XposedHelpers.findAndHookMethod(packageManagerService,
				"installPackage", Uri.class, IPackageInstallObserver.class, int.class, String.class, new XC_MethodHook()
bla bla...
But IPackageInstallObserver.class is not resolved (hidden, not in SDK). So, devs, how can I use it? Any workaround? I just need it to make hook working. For info, I am going to hook flags, not observer.
Last edited by pyler; 19th June 2014 at 08:20 PM.
19th June 2014, 08:36 PM   |  #2  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter: 14,981
 
2,383 posts
Join Date:Joined: Jan 2012
More
Quote:
Originally Posted by pyler

I have something like this..

Code:
XposedHelpers.findAndHookMethod(packageManagerService,
				"installPackage", Uri.class, IPackageInstallObserver.class, int.class, String.class, new XC_MethodHook()
bla bla...
But IPackageInstallObserver.class is not resolved (hidden, not in SDK). So, devs, how can I use it? Any workaround? I just need it to make hook working. For info, I am going to hook flags, not observer.

Simply use the string "android.content.pm.IPackageInstallObserver" instead of IPackageInstallObserver.class. You can do the same for the first class name:
Code:
XposedHelpers.findAndHookMethod("com.android.server.pm.PackageManagerService", null,
				"installPackage", Uri.class, "android.content.pm.IPackageInstallObserver", int.class, String.class, new XC_MethodHook()
bla bla...
(classloader is null here because the class is part of the BootClassLoader, usually you would use lpparam.classLoader instead)
19th June 2014, 08:58 PM   |  #3  
OP Senior Member
Thanks Meter: 569
 
473 posts
Join Date:Joined: Jan 2013
More
Quote:
Originally Posted by rovo89

Simply use the string "android.content.pm.IPackageInstallObserver" instead of IPackageInstallObserver.class. You can do the same for the first class name:

Code:
XposedHelpers.findAndHookMethod("com.android.server.pm.PackageManagerService", null,
				"installPackage", Uri.class, "android.content.pm.IPackageInstallObserver", int.class, String.class, new XC_MethodHook()
bla bla...
(classloader is null here because the class is part of the BootClassLoader, usually you would use lpparam.classLoader instead)

This is awesome. Thank you!
20th June 2014, 09:28 AM   |  #4  
Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: Jun 2014
Quote:
Originally Posted by rovo89

Simply use the string "android.content.pm.IPackageInstallObserver" instead of IPackageInstallObserver.class. You can do the same for the first class name:

Code:
XposedHelpers.findAndHookMethod("com.android.server.pm.PackageManagerService", null,
				"installPackage", Uri.class, "android.content.pm.IPackageInstallObserver", int.class, String.class, new XC_MethodHook()
bla bla...
(classloader is null here because the class is part of the BootClassLoader, usually you would use lpparam.classLoader instead)

hello @rovo89

I know that I can use the string ... instead of .....class to use "findAndHookMethod",
but if I want to get the parameter in "beforeHookedMethod", like this:
Code:
XposedHelpers.findAndHookMethod("com.example.main", null,
	"a", "com.example.Details", int.class, String.class, new XC_MethodHook() {
	@Override
	protected void beforeHookedMethod(MethodHookParam param)
			throws Throwable {
			int i = (Integer)param.args[1];
			String s = (String)param.args[2];
			.........					
			}
});
I can get the parameters like this: int i = (Integer)param.args[1]; String s = (String)param.args[2];
but what about the first one?
how to define "(Details)param.args[0]"?

thanks.
20th June 2014, 06:24 PM   |  #5  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter: 14,981
 
2,383 posts
Join Date:Joined: Jan 2012
More
Quote:
Originally Posted by aoei

I can get the parameters like this: int i = (Integer)param.args[1]; String s = (String)param.args[2];
but what about the first one?
how to define "(Details)param.args[0]"?

That's not possible. You have to assign it to an Object variable and then keep using reflection to get/set its fields and call methods. The methods in XposedHelpers make this very easy.
21st June 2014, 03:21 AM   |  #6  
Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: Jun 2014
Quote:
Originally Posted by rovo89

That's not possible. You have to assign it to an Object variable and then keep using reflection to get/set its fields and call methods. The methods in XposedHelpers make this very easy.

Got it! Thank you very much!
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes