From c97bf84aee812d272cf5fe30f399e9c871a360bb Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 15 Aug 2014 23:19:37 +0200 Subject: [PATCH] Handle special sensor delay values Refs #1878 --- src/biz/bokhorst/xprivacy/XSensorManager.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/biz/bokhorst/xprivacy/XSensorManager.java b/src/biz/bokhorst/xprivacy/XSensorManager.java index 8d6624e1e..c8980d40b 100644 --- a/src/biz/bokhorst/xprivacy/XSensorManager.java +++ b/src/biz/bokhorst/xprivacy/XSensorManager.java @@ -4,6 +4,7 @@ import java.util.List; import android.hardware.Sensor; +import android.hardware.SensorManager; import android.util.Log; public class XSensorManager extends XHook { @@ -78,7 +79,18 @@ else if (param.args.length > 0 && param.args[0] instanceof Integer) int type = ((Sensor) param.args[1]).getType(); if (type == Sensor.TYPE_GYROSCOPE || type == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) { int rateUs = (Integer) param.args[2]; - if (rateUs < cMaxRateUs) + + // http://developer.android.com/guide/topics/sensors/sensors_overview.html + if (rateUs == SensorManager.SENSOR_DELAY_NORMAL) + return; // 200,000 us + else if (rateUs == SensorManager.SENSOR_DELAY_UI) + return; // 60,000 us + else if (rateUs == SensorManager.SENSOR_DELAY_GAME) + return; // 20,000 us + else if (rateUs == SensorManager.SENSOR_DELAY_FASTEST) + ; // 0 us + + if (rateUs < cMaxRateUs) // 10,000 us if (isRestricted(param)) param.args[2] = cMaxRateUs; }