Post Reply

Replace method. Need help. PLease

OP S0bes

28th August 2014, 04:31 PM   |  #1  
S0bes's Avatar
OP Senior Member
Flag Tomsk
Thanks Meter: 326
 
317 posts
Join Date:Joined: Jan 2012
Donate to Me
More
Hi everyone. I ask for help. I literally beg for it..

com.android.dialer.dialpad.LatinSmartDialMap
You can see it here http://grepcode.com/file/repository....lMap.java?av=f
I only want to replace method . Any of them.
For example I want this method returns FALSE every time it's called.
Code:
@Override
   public boolean isValidDialpadAlphabeticChar(char ch) {
       return (ch >= 'a' && ch <= 'z');
   }
Here is my code
Code:
public class Fm implements IXposedHookLoadPackage {      
    
   
    public void handleLoadPackage(final LoadPackageParam loadpkg) throws Throwable { 
        
        if (loadpkg.packageName.equals("com.android.dialer")) { 
            ClassLoader classLoader = loadpkg.classLoader; 
            XC_MethodReplacement methodreplacer = new XC_MethodReplacement() {  
                protected Object replaceHookedMethod( 
                        XC_MethodHook.MethodHookParam paramAnonymousMethodHookParam)
                        throws Throwable {
                	 XposedBridge.log("ALLLLL RIGHTTTT . NOW We ARE IN. AND MADE IT FALSe"); 
                    return false;  
                   
                    
                }
            };
            XposedHelpers.findAndHookMethod("com.android.dialer.dialpad.LatinSmartDialMap", loadpkg.classLoader,
                    "isValidDialpadAlphabeticChar", Character.class, methodreplacer);
        }
               
        
    }
}
But this doesn't work
Here what I see in xposed log file:
java.lang.NoSuchMethodError: com.android.dialer.dialpad.LatinSmartDialMap#isVal idDialpadAlphabeticChar(java.lang.Character)#exact
at de.robv.android.xposed.XposedHelpers.findMethodExa ct(XposedHelpers.java:179)
at de.robv.android.xposed.XposedHelpers.findAndHookMe thod(XposedHelpers.java:129)
at de.robv.android.xposed.XposedHelpers.findAndHookMe thod(XposedHelpers.java:136)
at com.s0bes.fmspeaker.Fm.handleLoadPackage(Fm.java:3 0)
at de.robv.android.xposed.IXposedHookLoadPackage

BUUUT. If I will try to replace other method. For example
matchesCombination in com.android.dialer.dialpad.SmartDialNameMatcher (http://grepcode.com/file/repository....cher.java?av=f)
Here the part of code which was changed:
Code:
XposedHelpers.findAndHookMethod("com.android.dialer.dialpad.SmartDialNameMatcher", loadpkg.classLoader,
                    "matchesCombination", String.class, String.class, ArrayList.class, methodreplacer);
Now everything work...
So, it works with one thing and doesnt work with method I need
30th August 2014, 02:38 PM   |  #2  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 6,737
 
5,686 posts
Join Date:Joined: Aug 2012
Donate to Me
More
If you want to replace a method to return a consatnt, you can use the XC_MethodReplacement.returnConstant(…) shortcut. For example:
Code:
Select Code
XposedHelpers.findAndHookMethod("com.android.dialer.dialpad.SmartDialNameMatcher", loadpkg.classLoader,
                    "matchesCombination", String.class, String.class, ArrayList.class, XC_MethodReplacement.returnConstant(false));
As for your problem, you're trying to hook isValidDialpadAlphabeticChar(Character.class), but you should be hooking isValidDialpadAlphabeticChar(char.class). Just replace "Character.class" by "char.class" in your findAndHookMethod call.
The Following User Says Thank You to GermainZ For This Useful Post: [ View ]
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