I try to hook Settings.System.putInt
method which is static
. One of the calls for this method is done in setAirplaneModeOn
method of com.android.settings.AirplaneModeEnabler
class. It is placed in Settings
app of android. Also, putInt
method is used in com.android.systemui
.
However, following code doesn't hook putInt
method. It doesn't give any exception, but it also doesn't dump any log message with content "In android.provider.Settings.System
" which means beforeHookedMethod
is not called or it couldn't be hooked. Loaded app
logs are printed. Any help is greatly appreciated.
@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 version : 54
Android version: 4.2.2
Since Jelly Bean MR1 (4.2) the method setAirplaneModeOn
use putInt
in Settings.Global
instead Settings.System
as you can see here.
Your code should be modified like this:
@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");
}
});
}
I tested the updated code with KitKat 4.4.4 and it works correctly.