Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,805,734 Members 42,807 Now Online
XDA Developers Android and Mobile Development Forum

Replace method. Need help. PLease

Tip us?
 
S0bes
Old
#1  
S0bes's Avatar
Senior Member - OP
Thanks Meter 247
Posts: 263
Join Date: Jan 2012
Location: Tomsk

 
DONATE TO ME
Default Replace method. Need help. PLease

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
 
GermainZ
Old
#2  
GermainZ's Avatar
Forum Moderator / Recognized Developer
Thanks Meter 6,365
Posts: 5,459
Join Date: Aug 2012
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: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes