Samsung Galaxy Alpha (SM-G850) Gets Android 5.0

An Android 5.0 Lollipop update is finally available to download for the Samsung Galaxy … more

Do You Use 4:3 or 16:9 in the Camera App?

Every person has their own method of taking the best photos on their devices, but which aspect … more

LG G4 XDA Forum Opened

LG’s latest & greatest is just a few hours away from launching, and with so many power users that are … more

Android Wear Close to Running on Samsung Gear 2

Android is an OS that can sometimes be ported to run on devices not designed to … more
Post Reply Subscribe to Thread Email Thread

Hook method in handler

23rd August 2014, 07:30 PM |#1  
OP Senior Member
Thanks Meter: 864
 
More
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: 107
 
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: 864
 
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,171
 
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: 864
 
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,171
 
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: 864
 
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