Android 5.1.1 Omni ROM For Motorola Xoom

Back in Feb 2011, the Motorola Xoom became the first device to be sold with Android 3.0 … more

CleanSlate Brings Fingerprint Scanner Mod to HTC One M9+

Work of XDA Recognized Developer tbalden, CleanSlate custom kernel for the HTC … more

Sunday Debate: Which Factors Caused HTC’s Woes?

Join us in a fun Sunday Debate on HTC’s situation. Come with your … more

HTC’s New Ad Campaign And What It Really Means

HTC has just released three new blind test adverts comparing app loading … more

Hook method in handler

932 posts
Thanks Meter: 1,000
 
By pyler, Senior Member on 23rd August 2014, 07:30 PM
Post Reply Subscribe to Thread Email Thread
My code
Code:
XposedHelpers.findAndHookMethod("com.android.packageinstaller.InstallAppProgress$mHandler",
			lpparam.classLoader, "handleMessage", Message.class, new XC_MethodHook(){
				@Override
				protected void afterHookedMethod(MethodHookParam param)
				throws Throwable {...

https://github.com/android/platform_...pProgress.java

I want hook method "handleMessage". But it doesnt work. Method not found.
 
 
24th August 2014, 05:01 AM |#2  
riskey95's Avatar
Member
Flag Trenggalek
Thanks Meter: 108
 
More
Quote:
Originally Posted by pyler

My code

Code:
XposedHelpers.findAndHookMethod("com.android.packageinstaller.InstallAppProgress$mHandler",
lpparam.classLoader, "handleMessage", Message.class, new XC_MethodHook(){
@Override
protected void afterHookedMethod(MethodHookParam param)
throws Throwable {...

https://github.com/android/platform_...pProgress.java

I want hook method "handleMessage". But it doesnt work. Method not found.

are you sure InstallAppProgress$mHandler was exist? i've try to decompile Packageinstaller.apk of my phone and InstallAppProgress$mHandler doesn't exist, method handleMessage on my phone belong to InstallAppProgress$1.class
24th August 2014, 09:45 AM |#3  
OP Senior Member
Thanks Meter: 1,000
 
More
Quote:
Originally Posted by riskey95

are you sure InstallAppProgress$mHandler was exist? i've try to decompile Packageinstaller.apk of my phone and InstallAppProgress$mHandler doesn't exist, method handleMessage on my phone belong to InstallAppProgress$1.class

I tried to remove $mHandler but still it isnt working.

Maybe @GermainZ can help?
Last edited by pyler; 24th August 2014 at 12:26 PM.
24th August 2014, 04:26 PM |#4  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 8,294
 
More
That's an anonymous class, it'll be called InstallAppProgress$number. "number" is a counter (starts at 1, ends at n, where n is the number if anonymous classes in the enclosing class) chosen by the compiler at compile time. It's not guaranteed to stay the same.

You can hook it as riskey95 said, but it might not be InstallAppProgress$1 everywhere (could be e.g. InstallAppProgress$2). TIAS, and maybe blindly try hooking $1 to $3 if necessary (use a try/catch statement).
24th August 2014, 06:20 PM |#5  
OP Senior Member
Thanks Meter: 1,000
 
More
$1 worked. Now I need to get access to mDoneButton. But I cant since I am in InstallAppDetails$1.

Code:
@Override
			protected void afterHookedMethod(MethodHookParam param)
					throws Throwable {
				//prefs.reload();
				test = true;
				if (test) {
					Button mDone = (Button) XposedHelpers.getObjectField(
							param.thisObject, "mDoneButton");
					// todo
				}
			}
24th August 2014, 07:12 PM |#6  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 8,294
 
More
You can get the outer class using, for example:
Code:
 XposedHelpers.getObjectField(param.thisObject, "this$0");
(There might be an Xposed helper or an alternate method to do that, I can't remember and I can't check right now.)
24th August 2014, 07:54 PM |#7  
OP Senior Member
Thanks Meter: 1,000
 
More
Quote:
Originally Posted by GermainZ

You can get the outer class using, for example:

Code:
 XposedHelpers.getObjectField(param.thisObject, "this$0");
(There might be an Xposed helper or an alternate method to do that, I can't remember and I can't check right now.)

Fanstastic. All work now. I have to put your nick in XInstaller OP
Thank you.

p.s: found. getSurroundingThis
14th October 2014, 02:59 PM |#8  
Member
Thanks Meter: 0
 
More
Hi,

can you please share the final code that worked for you in this case:

XposedHelpers.findAndHookMethod("com.android.packa geinstaller.InstallAppProgress$mHandler",
lpparam.classLoader, "handleMessage", Message.class, new XC_MethodHook(){
@override
protected void afterHookedMethod(MethodHookParam param)
throws Throwable {...

Thanks!
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes