1

我尝试挂钩Settings.System.putInt方法是static. 此方法的调用之一是在类的方法中完成setAirplaneModeOncom.android.settings.AirplaneModeEnabler。它被放置在Settingsandroid的应用程序中。此外,putInt方法用于com.android.systemui.

但是,以下代码不会挂钩putInt方法。它没有给出任何异常,但它也不会转储任何带有内容“ In android.provider.Settings.System”的日志消息,这意味着beforeHookedMethod没有被调用或者它不能被钩住。Loaded app打印日志。任何帮助是极大的赞赏。

@Override
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
    if (!( lpparam.packageName.equals("com.android.systemui") || lpparam.packageName.equals("com.android.settings"))) {
        return;
    }
    XposedBridge.log("Loaded app: " + lpparam.packageName);
    final Class<?> mClass = XposedHelpers.findClass("android.provider.Settings$System", lpparam.classLoader);
    findAndHookMethod(mClass, "putInt", ContentResolver.class, String.class, "int",  new XC_MethodHook() {
        @Override
        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
            XposedBridge.log("In android.provider.Settings.System");
        }
    });
}

Xposed-Framework 版本:54

安卓版本:4.2.2

4

1 回答 1

1

由于 Jelly Bean MR1 (4.2) 该方法setAirplaneModeOn使用putIntinSettings.Global代替Settings.System,如您在此处看到的那样。

你的代码应该这样修改:

@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
    if (!(lpparam.packageName.equals("com.android.systemui") || lpparam.packageName.equals("com.android.settings"))) {
        return;
    }
    XposedBridge.log("Loaded app: " + lpparam.packageName);
    final Class<?> mClass = XposedHelpers.findClass("android.provider.Settings$Global", lpparam.classLoader);
    findAndHookMethod(mClass, "putInt", ContentResolver.class, String.class, int.class, new XC_MethodHook() {
        @Override
        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
            XposedBridge.log("In android.provider.Settings.Global");
        }
    });
}

我用 KitKat 4.4.4 测试了更新的代码,它工作正常。

于 2015-05-09T17:12:26.830 回答