两个模块挂钩相同的方法

时间:2019-03-23 10:31:40

标签: java xposed

我迷上了方法getIntExtra,但是另一个开发人员的另一个模块也迷上了这个方法。钩子之后,我无法控制setResult()。 Xposed可以设置模块的优先级吗?

 XposedHelpers.findAndHookMethod(
            "android.content.Intent", lpparam.classLoader,"getIntExtra", String.class, int.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                }

                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    Intent intent = (Intent) param.thisObject;
                    final String action = intent.getAction();
                    if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
                        if (BatteryManager.EXTRA_LEVEL.equals(param.args[0] + "")) {

                            Random r = new Random();
                            int I =r.nextInt(100);
                            param.setResult(I);
                            Log.e(TAG, "getIntExtra: "+param.args[0]+" Value: "+ I);
                        }
                        else if ("status".equals(param.args[0] + "")) {
                            XposedBridge.log("status");
                            Log.e(TAG, "getIntExtra: "+param.args[0]);
                            param.setResult(BatteryManager.BATTERY_STATUS_CHARGING);
                        }
                    }
                }
            }
    );

0 个答案:

没有答案