Backup+ Lets You Backup Your App Data on Android Lollipop

Even though Android 5.0 Lollipop hasn’t yet seen its official release, quite … more

TechTalk Compiles All the Android News You Need in One App

If you’re as obsessed with mobile devices as the vast majority of our forum … more

Android App Review: Google Inbox to Improve Your Life – XDA TV

Recently, Google+ exploded with the announcement of Google Inbox, as … more

Damp the LG G3 Thermal Throttling

As our mobile devices grow thinner and more powerfulwith each passing generation, it’s inevitable … more
Post Reply

Hook method in handler

OP pyler

23rd August 2014, 07:30 PM   |  #1  
OP Senior Member
Thanks Meter: 484
 
399 posts
Join Date:Joined: Jan 2013
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: 97
 
90 posts
Join Date:Joined: Mar 2013
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: 484
 
399 posts
Join Date:Joined: Jan 2013
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: 6,767
 
5,701 posts
Join Date:Joined: Aug 2012
Donate to Me
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: 484
 
399 posts
Join Date:Joined: Jan 2013
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: 6,767
 
5,701 posts
Join Date:Joined: Aug 2012
Donate to Me
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: 484
 
399 posts
Join Date:Joined: Jan 2013
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
 
47 posts
Join Date:Joined: Aug 2014
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


Top Threads in Xposed General by ThreadRank