[Java] 纯文本查看 复制代码 package com.my.alisport;
/**
* Created by GZP on 2017/7/26.
*/
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.util.SparseArray;
import java.lang.reflect.Field;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import static de.robv.android.xposed.XposedBridge.log;
import static de.robv.android.xposed.XposedHelpers.findClass;
/**
* Created by Administrator on 2016/5/11.
*/
public class WeixinSport implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
// filter
if (!loadPackageParam.packageName.equals("com.tencent.mm")) {
return;
}
log("运动 packageName: " + loadPackageParam.packageName);
final Class<?> sensorEL = findClass("android.hardware.SystemSensorManager$SensorEventQueue", loadPackageParam.classLoader);
XposedBridge.hookAllMethods(sensorEL, "dispatchSensorEvent", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
int intValue = ((Integer) param.args[0]).intValue();
log("intValue: " + intValue);
Field declaredField = param.thisObject.getClass().getDeclaredField("mSensorsEvents");
declaredField.setAccessible(true);
Sensor sensor = ((SensorEvent) ((SparseArray) declaredField.get(param.thisObject)).get(intValue)).sensor;
if (sensor == null) {
log("传感器为NULL");
return;
}
int sensortype = sensor.getType();
log("sensortype: " + sensortype);
if (sensortype == 19 || sensortype == 18) {
float nowstep = ((float[]) param.args[1])[0];
((float[]) param.args[1])[0] = nowstep + 30;
}
}
});
}
}
跟你的没啥区别 算是一致
xposed_init 文件 :com.my.alisport.WeixinSport |