Java Code Examples for de.robv.android.xposed.XposedHelpers#findMethodExactIfExists()

The following examples show how to use de.robv.android.xposed.XposedHelpers#findMethodExactIfExists() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModDialer24.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private static ClassInfo resolveCallCardFragment(ClassLoader cl) {
    ClassInfo info = null;
    String[] CLASS_NAMES = new String[] { "com.android.incallui.CallCardFragment", "ayv" };
    String[] METHOD_NAMES = new String[] { "setDrawableToImageView" };
    for (String className : CLASS_NAMES) {
        Class<?> clazz = XposedHelpers.findClassIfExists(className, cl);
        if (clazz == null || !Fragment.class.isAssignableFrom(clazz))
            continue;
        info = new ClassInfo(clazz);
        for (String methodName : METHOD_NAMES) {
            if (methodName.equals("setDrawableToImageView")) {
                for (String realMethodName : new String[] { methodName, "b" }) {
                    Method m = XposedHelpers.findMethodExactIfExists(clazz, realMethodName,
                        Drawable.class);
                    if (m != null) {
                        info.methods.put(methodName, realMethodName);
                        break;
                    }
                }
            }
        }
    }
    return info;
}
 
Example 2
Source File: ModDialer24.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private static ClassInfo resolveAnswerFragment(ClassLoader cl) {
    ClassInfo info = null;
    String[] CLASS_NAMES = new String[] { "com.android.incallui.AnswerFragment", "bbw", "bbx" };
    String[] METHOD_NAMES = new String[] { "onShowAnswerUi" };
    for (String className : CLASS_NAMES) {
        Class<?> clazz = XposedHelpers.findClassIfExists(className, cl);
        if (clazz == null || !Fragment.class.isAssignableFrom(clazz))
            continue;
        info = new ClassInfo(clazz);
        for (String methodName : METHOD_NAMES) {
            if (methodName.equals("onShowAnswerUi")) {
                for (String realMethodName : new String[] { methodName, "a" }) {
                    Method m = XposedHelpers.findMethodExactIfExists(clazz, realMethodName,
                        boolean.class);
                    if (m != null) {
                        info.methods.put(methodName, realMethodName);
                        break;
                    }
                }
            }
        }
    }
    return info;
}
 
Example 3
Source File: ModDialer24.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private static ClassInfo resolveCallButtonFragment(ClassLoader cl) {
    ClassInfo info = null;
    String[] CLASS_NAMES = new String[] { "com.android.incallui.CallButtonFragment" };
    String[] METHOD_NAMES = new String[] { "setEnabled" };
    for (String className : CLASS_NAMES) {
        Class<?> clazz = XposedHelpers.findClassIfExists(className, cl);
        if (clazz == null || !Fragment.class.isAssignableFrom(clazz))
            continue;
        info = new ClassInfo(clazz);
        for (String methodName : METHOD_NAMES) {
            if (methodName.equals("setEnabled")) {
                for (String realMethodName : new String[] { methodName, "a" }) {
                    Method m = XposedHelpers.findMethodExactIfExists(clazz, realMethodName,
                        boolean.class);
                    if (m != null) {
                        info.methods.put(methodName, realMethodName);
                        break;
                    }
                }
            }
        }
    }
    return info;
}
 
Example 4
Source File: PermissionManagerServiceHook.java    From XposedSmsCode with GNU General Public License v3.0 5 votes vote down vote up
private Method findTargetMethod() {
    Class<?> pmsClass = XposedHelpers.findClass(CLASS_PERMISSION_MANAGER_SERVICE, mClassLoader);
    Class<?> packageClass = XposedHelpers.findClass(CLASS_PACKAGE_PARSER_PACKAGE, mClassLoader);
    Class<?> callbackClass = XposedHelpers.findClassIfExists(CLASS_PERMISSION_CALLBACK, mClassLoader);
    if (callbackClass == null) {
        // Android Q PermissionCallback 不一样
        callbackClass = XposedWrapper.findClass(CLASS_PERMISSION_CALLBACK_Q, mClassLoader);
    }

    Method method = XposedHelpers.findMethodExactIfExists(pmsClass, "grantPermissions",
            /* PackageParser.Package pkg   */ packageClass,
            /* boolean replace             */ boolean.class,
            /* String packageOfInterest    */ String.class,
            /* PermissionCallback callback */ callbackClass);

    if (method == null) { // method grantPermissions() not found
        // Android Q
        method = XposedHelpers.findMethodExactIfExists(pmsClass, "restorePermissionState",
                /* PackageParser.Package pkg   */ packageClass,
                /* boolean replace             */ boolean.class,
                /* String packageOfInterest    */ String.class,
                /* PermissionCallback callback */ callbackClass);
        if (method == null) { // method restorePermissionState() not found
            Method[] _methods = XposedHelpers.findMethodsByExactParameters(pmsClass, Void.TYPE,
                    /* PackageParser.Package pkg   */ packageClass,
                    /* boolean replace             */ boolean.class,
                    /* String packageOfInterest    */ String.class,
                    /* PermissionCallback callback */ callbackClass);
            if (_methods != null && _methods.length > 0) {
                method = _methods[0];
            }
        }
    }
    return method;
}
 
Example 5
Source File: ModDialer24.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static ClassInfo resolveDialtactsActivity(ClassLoader cl) {
    ClassInfo info = null;
    String[] CLASS_NAMES = new String[] { CLASS_DIALTACTS_ACTIVITY };
    String[] METHOD_NAMES = new String[] { "displayFragment" };
    for (String className : CLASS_NAMES) {
        Class<?> clazz = XposedHelpers.findClassIfExists(className, cl);
        if (clazz == null || !Activity.class.isAssignableFrom(clazz))
            continue;
        info = new ClassInfo(clazz);
        for (String methodName : METHOD_NAMES) {
            if (methodName.equals("displayFragment")) {
                for (String realMethodName : new String[] { methodName, "c" }) {
                    Method m = XposedHelpers.findMethodExactIfExists(clazz, realMethodName,
                        Intent.class);
                    if (m != null) {
                        info.methods.put(methodName, realMethodName);
                        if (realMethodName.equals(methodName)) {
                            info.extra = "showDialpadFragment";
                        } else {
                            info.extra = "b";
                        }
                        break;
                    }
                }
            }
        }
    }
    return info;
}
 
Example 6
Source File: ModDialer24.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static ClassInfo resolveDialpadFragment(ClassLoader cl) {
    ClassInfo info = null;
    String[] CLASS_NAMES = new String[] { "com.android.dialer.app.dialpad.DialpadFragment" };
    String[] METHOD_NAMES = new String[] { "onResume", "playTone" };
    for (String className : CLASS_NAMES) {
        Class<?> clazz = XposedHelpers.findClassIfExists(className, cl);
        if (clazz == null || !Fragment.class.isAssignableFrom(clazz))
            continue;
        info = new ClassInfo(clazz);
        for (String methodName : METHOD_NAMES) {
            Method m = null;
            if (methodName.equals("onResume")) {
                m = XposedHelpers.findMethodExactIfExists(clazz, methodName);
            } else if (methodName.equals("playTone")) {
                for (String realMethodName : new String[] { methodName, "a" }) {
                    m = XposedHelpers.findMethodExactIfExists(clazz, realMethodName,
                        int.class, int.class);
                    if (m != null) break;
                }
            }
            if (m != null) {
                info.methods.put(methodName, m.getName());
            }
        }
    }
    return info;
}
 
Example 7
Source File: ModDialer25.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static ClassInfo resolveDialtactsActivity(ClassLoader cl) {
    ClassInfo info = null;
    String[] CLASS_NAMES = new String[]{CLASS_DIALTACTS_APP_ACTIVITY, CLASS_DIALTACTS_ACTIVITY};
    String[] METHOD_NAMES = new String[]{"displayFragment"};
    for (String className : CLASS_NAMES) {
        Class<?> clazz = XposedHelpers.findClassIfExists(className, cl);
        if (clazz == null || !Activity.class.isAssignableFrom(clazz)) {
            continue;
        }
        info = new ClassInfo(clazz);
        for (String methodName : METHOD_NAMES) {
            if (methodName.equals("displayFragment")) {
                for (String realMethodName : new String[]{methodName, "a", "c", "b"}) {
                    Method m = XposedHelpers.findMethodExactIfExists(clazz, realMethodName,
                            Intent.class);
                    if (m != null) {
                        info.methods.put(methodName, realMethodName);
                        if (realMethodName.equals(methodName)) {
                            info.extra = "showDialpadFragment";
                        } else if (realMethodName.equals("c")) {
                            info.extra = "b";
                        } else {
                            info.extra = "c";
                        }
                        break;
                    }
                }
            }
        }
    }
    return info;
}
 
Example 8
Source File: ModDialer25.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static ClassInfo resolveDialpadFragment(ClassLoader cl) {
    ClassInfo info = null;
    String[] CLASS_NAMES = new String[]{CLASS_DIALTACTS_APP_FRAGMENT, CLASS_DIALTACTS_FRAGMENT};
    String[] METHOD_NAMES = new String[]{"onResume", "playTone"};
    for (String className : CLASS_NAMES) {
        Class<?> clazz = XposedHelpers.findClassIfExists(className, cl);
        if (clazz == null || !Fragment.class.isAssignableFrom(clazz))
            continue;
        info = new ClassInfo(clazz);
        for (String methodName : METHOD_NAMES) {
            Method m = null;
            if (methodName.equals("onResume")) {
                m = XposedHelpers.findMethodExactIfExists(clazz, methodName);
            } else if (methodName.equals("playTone")) {
                for (String realMethodName : new String[]{methodName, "a"}) {
                    m = XposedHelpers.findMethodExactIfExists(clazz, realMethodName,
                            int.class, int.class);
                    if (m != null) break;
                }
            }
            if (m != null) {
                info.methods.put(methodName, m.getName());
            }
        }
    }
    return info;
}
 
Example 9
Source File: BaseHandler.java    From xposed-rimet with Apache License 2.0 4 votes vote down vote up
public Method findMethodExactIfExists(String className, String methodName, Object... parameterTypes) {
    return XposedHelpers.findMethodExactIfExists(className,
            mPluginManager.getLoadPackageParam().classLoader, methodName, parameterTypes);
}
 
Example 10
Source File: BasePlugin.java    From xposed-rimet with Apache License 2.0 4 votes vote down vote up
public Method findMethodExactIfExists(String className, String methodName, Object... parameterTypes) {
    return XposedHelpers.findMethodExactIfExists(className, mParam.classLoader, methodName, parameterTypes);
}