sensorManager.registerListener(new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
}, sensorGravity, SensorManager.SENSOR_DELAY_NORMAL);
怎么hook这里的SensorEventListener?
目标是hook住android.hardware.SensorManager.registerListener(SensorEventListener listener, Sensor sensor, int samplingPeriodUs)
的listener
里的onSensorChanged(SensorEvent event)
这个函数.
XposedHelpers.findAndHookMethod("android.hardware.SensorManager", loadPackageParam.classLoader, "registerListener", SensorEvent.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
SensorEventListener event = (SensorEventListener) param.args[0];
}
});
在官方教程里找不到描述这种hook的方法
亲测:使用美元符号连接内部类,见:
http://stackoverflow.com/questions/22528...
我不了解xposed(汗),不过Java类中的匿名类编译时是作为子类处理,并独立生成class文件的,例如SensorManager$1.class,建议可以从这个角度研究一下