Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,809,424 Members 35,995 Now Online
XDA Developers Android and Mobile Development Forum

Hook method in handler

Tip us?
 
pyler
Old
#1  
Senior Member - OP
Thanks Meter 441
Posts: 358
Join Date: Jan 2013
Default Hook method in handler

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.
 
riskey95
Old
#2  
riskey95's Avatar
Member
Thanks Meter 83
Posts: 74
Join Date: Mar 2013
Location: Trenggalek
Quote:
Originally Posted by pyler View Post
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
Phone: LG Optimus L7 II Dual P715
ROM: MIUI V5 4.7.18
Recovery: CWM v6.0.3.7
 
pyler
Old
(Last edited by pyler; 24th August 2014 at 12:26 PM.)
#3  
Senior Member - OP
Thanks Meter 441
Posts: 358
Join Date: Jan 2013
Quote:
Originally Posted by riskey95 View Post
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?
 
GermainZ
Old
#4  
GermainZ's Avatar
Forum Moderator / Recognized Developer
Thanks Meter 6,397
Posts: 5,476
Join Date: Aug 2012
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).
 
pyler
Old
#5  
Senior Member - OP
Thanks Meter 441
Posts: 358
Join Date: Jan 2013
$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
				}
			}
 
GermainZ
Old
#6  
GermainZ's Avatar
Forum Moderator / Recognized Developer
Thanks Meter 6,397
Posts: 5,476
Join Date: Aug 2012
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.)
 
pyler
Old
#7  
Senior Member - OP
Thanks Meter 441
Posts: 358
Join Date: Jan 2013
Quote:
Originally Posted by GermainZ View Post
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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Flyme OS Finds Its Way to the Google Nexus 5

Flyme OS is a heavily modified Android variantdeveloped by the Meizu team for their MX … more

MultiROM Makes Its Way to the LG G2

Over the last few weeks, we’ve seen quite a fewflagship (and former flagship) devicesget to … more

Jair Player with a Major Update–Here’s What’s New!

Back in May, we talked a bit aboutJair Player, a nice looking music … more