Java Code Examples for de.robv.android.xposed.XposedHelpers#findClassIfExists()
The following examples show how to use
de.robv.android.xposed.XposedHelpers#findClassIfExists() .
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 |
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 |
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 |
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: Enhancement.java From EdXposedManager with GNU General Public License v3.0 | 5 votes |
private static void hookAllMethods(String className, ClassLoader classLoader, String methodName, XC_MethodHook callback) { try { final Class<?> hookClass = XposedHelpers.findClassIfExists(className, classLoader); if (hookClass == null || XposedBridge.hookAllMethods(hookClass, methodName, callback).size() == 0) XposedBridge.log("Failed to hook " + methodName + " method in " + className); } catch (Throwable t) { XposedBridge.log(t); } }
Example 5
Source File: XposedInit.java From dumpDex with MIT License | 5 votes |
@Override public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) { Class<?> clazz = null; for (String aPackage : packages) { clazz = XposedHelpers.findClassIfExists(aPackage, lpparam.classLoader); if (clazz != null) { log("find class:" + aPackage); break; } } if (clazz == null) { return; } final String packageName = lpparam.packageName; XposedBridge.log(packageName); try { initDexMethod(); } catch (Throwable t) { //Android版本不支持该插件 log(t); return; } XposedHelpers.findAndHookMethod("java.lang.ClassLoader", lpparam.classLoader, "loadClass", String.class, boolean.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Class c = (Class) param.getResult(); if (c == null) { return; } Object object = getDexMethod.invoke(c); byte[] array = (byte[]) getBytesMethod.invoke(object); if (array == null) { return; } saveData(packageName, array); } }); }
Example 6
Source File: PermissionManagerServiceHook.java From XposedSmsCode with GNU General Public License v3.0 | 5 votes |
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 7
Source File: ModDialer24.java From GravityBox with Apache License 2.0 | 5 votes |
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 8
Source File: ModDialer24.java From GravityBox with Apache License 2.0 | 5 votes |
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 9
Source File: ModDialer25.java From GravityBox with Apache License 2.0 | 5 votes |
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 10
Source File: ModDialer25.java From GravityBox with Apache License 2.0 | 5 votes |
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 11
Source File: RetalDriverApplication.java From ratel with Apache License 2.0 | 4 votes |
@Override protected void attachBaseContext(Context base) { //第一步需要call supper,否则Application并不完整,还无法作为context使用,当然此时base context是可用状态 super.attachBaseContext(base); //exposed框架,在driver下面定义,所以需要在替换classloader之前,完成exposed框架的so库加载 ExposedBridge.initOnce(this, getApplicationInfo(), getClassLoader()); if (!checkSupport()) { throw new IllegalStateException("epic 不支持的版本"); } //释放两个apk,一个是xposed模块,一个是原生的apk,原生apk替换为当前的Application作为真正的宿主,xposed模块apk在Application被替换之前作为补丁代码注入到当前进程 releaseApkFiles(); //替换classloader Class<?> contextImplClazz = XposedHelpers.findClassIfExists("android.app.ContextImpl", base.getClassLoader()); Object contextImpl = XposedHelpers.callStaticMethod(contextImplClazz, "getImpl", base); Object loadApk = XposedHelpers.getObjectField(contextImpl, "mPackageInfo"); ClassLoader parentClassLoader = RetalDriverApplication.class.getClassLoader(); try { // Class<?> aClass = XposedHelpers.findClass("android.app.LoadedApk", RetalDriverApplication.class.getClassLoader()); parentClassLoader = (ClassLoader) XposedHelpers.getObjectField(loadApk, "mClassLoader"); } catch (Exception e) { //ignore } String originApkSourceDir = new File(ratelWorkDir(this), originAPKFileName).getAbsolutePath(); PathClassLoader originClassLoader = new PathClassLoader(originApkSourceDir, parentClassLoader); XposedHelpers.setObjectField(loadApk, "mClassLoader", originClassLoader); //context中的resource,仍然绑定在老的apk环境下,现在把他们迁移 ApplicationInfo appinfoInLoadedApk = (ApplicationInfo) XposedHelpers.getObjectField(loadApk, "mApplicationInfo"); appinfoInLoadedApk.sourceDir = originApkSourceDir; XposedHelpers.setObjectField(loadApk, "mAppDir", originApkSourceDir); XposedHelpers.setObjectField(loadApk, "mResDir", originApkSourceDir); XposedHelpers.setObjectField(loadApk, "mResources", null); Resources resources = (Resources) XposedHelpers.callMethod(loadApk, "getResources", currentActivityThread()); if (resources != null) { XposedHelpers.setObjectField(contextImpl, "mResources", resources); } //替换之后,再也无法访问容器apk里面的资源了,容器中的所有资源全部被替换为原始apk的资源 loadResources(originApkSourceDir); }
Example 12
Source File: XHelper.java From AideHelper with MIT License | 2 votes |
/** * 获取Class * * @param name 类的路径 * @return Class */ public static Class findClass(String name) { return XposedHelpers.findClassIfExists(name, getClassLoader()); }