A Look at the Telegram+ Situation

more

Remove Unlocked Warning Message from Moto E 2015

more

Multi Boot: The Fall of Nandroid?

more

NVIDIA SHIELD: The Tegra X1 Powered Android TV Box

The post NVIDIA SHIELD: The Tegra X1 Powered Android TV Box appeared first on … more
Post Reply

Hook method in handler

OP pyler

23rd August 2014, 08:30 PM   |  #1  
OP Senior Member
Thanks Meter: 784
 
719 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, 06:01 AM   |  #2  
riskey95's Avatar
Member
Flag Trenggalek
Thanks Meter: 107
 
91 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, 10:45 AM   |  #3  
OP Senior Member
Thanks Meter: 784
 
719 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 01:26 PM.
24th August 2014, 05:26 PM   |  #4  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 7,909
 
6,137 posts
Join Date:Joined: Aug 2012
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, 07:20 PM   |  #5  
OP Senior Member
Thanks Meter: 784
 
719 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, 08:12 PM   |  #6  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 7,909
 
6,137 posts
Join Date:Joined: Aug 2012
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, 08:54 PM   |  #7  
OP Senior Member
Thanks Meter: 784
 
719 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, 03:59 PM   |  #8  
Member
Thanks Meter: 0
 
53 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