Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1419)

Unified Diff: device/generic_sensor/android/java/src/org/chromium/device/sensors/PlatformSensor.java

Issue 2465363004: [Sensors] Consider maximum supported frequency (Closed)
Patch Set: Comments from Alex Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/generic_sensor/android/java/src/org/chromium/device/sensors/PlatformSensor.java
diff --git a/device/generic_sensor/android/java/src/org/chromium/device/sensors/PlatformSensor.java b/device/generic_sensor/android/java/src/org/chromium/device/sensors/PlatformSensor.java
index 2da8e583d0aeb2875e2f46366f49737d634104bf..1d825fe3ac83e358ca644aaa61cbefa298fdf031 100644
--- a/device/generic_sensor/android/java/src/org/chromium/device/sensors/PlatformSensor.java
+++ b/device/generic_sensor/android/java/src/org/chromium/device/sensors/PlatformSensor.java
@@ -22,6 +22,7 @@ import java.util.List;
@JNINamespace("device")
public class PlatformSensor implements SensorEventListener {
private static final double MICROSECONDS_IN_SECOND = 1000000;
+ private static final double SECONDS_IN_MICROSECOND = 0.000001d;
timvolodine 2016/11/03 17:32:55 why not use import java.util.concurrent.TimeUnit f
Mikhail 2016/11/04 21:17:44 That API operates with 'long' type and loses preci
private static final double SECONDS_IN_NANOSECOND = 0.000000001d;
/**
@@ -124,6 +125,17 @@ public class PlatformSensor implements SensorEventListener {
}
/**
+ * Returns maximum sampling frequency supported by the sensor.
+ *
+ * @return double frequency in Hz.
+ */
+ @CalledByNative
+ protected double getMaximumSupportedFrequency() {
+ if (mMinDelayUsec == 0) return getDefaultConfiguration();
+ return 1 / (mMinDelayUsec * SECONDS_IN_MICROSECOND);
+ }
+
+ /**
* Requests sensor to start polling for data.
*
* @return boolean true if successful, false otherwise.

Powered by Google App Engine
This is Rietveld 408576698