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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f54ab6bac22b2c1996d7db0812c2e2157307b02f |
--- /dev/null |
+++ b/device/generic_sensor/android/java/src/org/chromium/device/sensors/PlatformSensor.java |
@@ -0,0 +1,51 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.device.sensors; |
+ |
+import org.chromium.base.annotations.CalledByNative; |
+import org.chromium.base.annotations.JNINamespace; |
+ |
+import java.nio.ByteBuffer; |
+import java.nio.ByteOrder; |
+ |
+/** |
+ * Base class that is wrapped by device::PlatformSensorAndroid and should be used to implement |
+ * concrete sensors. Lifetime is controlled by the device::PlatformSensorAndroid. |
+ */ |
+@JNINamespace("device") |
+public abstract class PlatformSensor { |
Ted C
2016/09/01 00:12:36
seeing that we are in the generic_sensor directory
shalamov
2016/09/06 12:36:43
Agree, removed abstraction, if in the future non S
|
+ protected long mNativePlatformSensorAndroid; |
Ted C
2016/09/01 00:12:36
I think this should be private. Then expose helpe
shalamov
2016/09/06 12:36:43
Done.
|
+ protected ByteBuffer mBuffer; |
+ protected ByteBuffer mSensorReadingData; |
+ |
+ protected PlatformSensor() {} |
Ted C
2016/09/01 00:12:36
you want this protected to prevent sensors from be
shalamov
2016/09/06 12:36:43
added public static create() that returns null in
|
+ |
+ @CalledByNative |
+ private void initPlatformSensorAndroid(long nativePlatformSensorAndroid, ByteBuffer buffer) { |
+ mNativePlatformSensorAndroid = nativePlatformSensorAndroid; |
+ mBuffer = buffer; |
Ted C
2016/09/01 00:12:36
I would just have another abstract method that exp
shalamov
2016/09/06 12:36:43
not needed, since I merged classes.
|
+ mSensorReadingData = ByteBuffer.allocate(mBuffer.capacity()); |
+ mSensorReadingData.order(ByteOrder.nativeOrder()); |
+ } |
+ |
+ @CalledByNative |
+ protected abstract int getReportingMode(); |
Ted C
2016/09/01 00:12:36
javadoc for all non-private methods
shalamov
2016/09/06 12:36:43
Done.
|
+ |
+ @CalledByNative |
+ protected abstract PlatformSensorConfiguration getDefaultConfiguration(); |
+ |
+ @CalledByNative |
+ protected abstract boolean startSensor(PlatformSensorConfiguration configuration); |
+ |
+ @CalledByNative |
+ protected abstract void stopSensor(); |
+ |
+ @CalledByNative |
+ protected abstract boolean checkSensorConfiguration(PlatformSensorConfiguration configuration); |
+ |
+ protected native void nativeNotifyPlatformSensorReadingChanged( |
+ long nativePlatformSensorAndroid); |
+ protected native void nativeNotifyPlatformSensorError(long nativePlatformSensorAndroid); |
+} |