• XposedNoRebootModuleSample 不需要频繁重启调试的Xposed 模块源码例子


    XposedNoRebootModuleSample(不需要频繁重启调试的Xposed 模块源码例子)
    Xposed Module Sample No Need To Reboot When Debug

    github:https://github.com/asiontang/XposedNoRebootModuleSample
        @Override
        public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable
        {
            if (!"cn.asiontang.location.demo".equals(loadPackageParam.packageName))
                return;
            try
            {
                //在发布时,直接调用即可。
                if (!BuildConfig.DEBUG)
                {
                    handleLoadPackage4release(loadPackageParam);
                    return;
                }
                //在调试模式为了不频繁重启,使用反射的方式调用自身的指定函数。
    
                /*【方法2】*/
                final String packageName = MainXposedHook.class.getPackage().getName();
                String filePath = String.format("/data/app/%s-%s.apk", packageName, 1);
                if (!new File(filePath).exists())
                {
                    filePath = String.format("/data/app/%s-%s.apk", packageName, 2);
                    if (!new File(filePath).exists())
                    {
                        XposedBridge.log("Error:在/data/app找不到APK文件" + packageName);
                        return;
                    }
                }
                final PathClassLoader pathClassLoader = new PathClassLoader(filePath, ClassLoader.getSystemClassLoader());
                final Class<?> aClass = Class.forName(packageName + "." + MainXposedHook.class.getSimpleName(), true, pathClassLoader);
                final Method aClassMethod = aClass.getMethod("handleLoadPackage4release", XC_LoadPackage.LoadPackageParam.class);
                aClassMethod.invoke(aClass.newInstance(), loadPackageParam);
    
                /*【方法1】:无法达到效果*/
                //final Class<MainActivity> pathClassLoader = MainActivity.class;
                //final Class<?> aClass = Class.forName(pathClassLoader.getPackage().getName() + "." + MainXposedHook.class.getSimpleName(), true, pathClassLoader.getClassLoader());
                //final Method aClassMethod = aClass.getMethod("handleLoadPackage4release", XC_LoadPackage.LoadPackageParam.class);
                //aClassMethod.invoke(aClass.newInstance(), loadPackageParam);
            }
            catch (final Exception e)
            {
                XposedBridge.log(e);
            }
        }
    
        public void handleLoadPackage4release(final XC_LoadPackage.LoadPackageParam loadPackageParam)
        {
            XposedBridge.log("------------5");
        }
    作者:Asion Tang
    凡是没有注明[转载]的文章,本Blog发表的文章版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    CV方向的高效阅读英文文献方法总结
    数据增强方法总结
    CNN结构演变总结(三)设计原则
    CNN结构演变总结(二)轻量化模型
    CNN结构演变总结(一)经典模型
    CNN可视化技术总结(四)--可视化工具与项目
    Codeforces972 D. Kuro and GCD and XOR and SUM 01Trie
    Codeforces 982 D. Shark
    Codeforces Round #700 (Div. 2) A~D题解
    codeforces 1004 D. Sonya and Matrix 构造
  • 原文地址:https://www.cnblogs.com/AsionTang/p/5478761.html
Copyright © 2020-2023  润新知