| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_ | 5 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_ |
| 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_ | 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_ |
| 7 | 7 |
| 8 #include "device/generic_sensor/platform_sensor.h" | 8 #include "device/generic_sensor/platform_sensor.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 class SingleThreadTaskRunner; | 13 class SingleThreadTaskRunner; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace device { | 16 namespace device { |
| 17 | 17 |
| 18 class PlatformSensorAndroid : public PlatformSensor { | 18 class PlatformSensorAndroid : public PlatformSensor { |
| 19 public: | 19 public: |
| 20 // Register C++ methods exposed to Java using JNI. | 20 // Register C++ methods exposed to Java using JNI. |
| 21 static bool RegisterJNI(JNIEnv* env); | 21 static bool RegisterJNI(JNIEnv* env); |
| 22 | 22 |
| 23 PlatformSensorAndroid(mojom::SensorType type, | 23 PlatformSensorAndroid(mojom::SensorType type, |
| 24 mojo::ScopedSharedBufferMapping mapping, | 24 mojo::ScopedSharedBufferMapping mapping, |
| 25 PlatformSensorProvider* provider, | 25 PlatformSensorProvider* provider, |
| 26 const base::android::JavaRef<jobject>& java_sensor); | 26 const base::android::JavaRef<jobject>& java_sensor); |
| 27 | 27 |
| 28 mojom::ReportingMode GetReportingMode() override; | 28 mojom::ReportingMode GetReportingMode() override; |
| 29 PlatformSensorConfiguration GetDefaultConfiguration() override; | 29 PlatformSensorConfiguration GetDefaultConfiguration() override; |
| 30 double GetMaximumSupportedFrequency() override; |
| 30 | 31 |
| 31 void NotifyPlatformSensorError(JNIEnv*, | 32 void NotifyPlatformSensorError(JNIEnv*, |
| 32 const base::android::JavaRef<jobject>& caller); | 33 const base::android::JavaRef<jobject>& caller); |
| 33 | 34 |
| 34 void UpdatePlatformSensorReading( | 35 void UpdatePlatformSensorReading( |
| 35 JNIEnv*, | 36 JNIEnv*, |
| 36 const base::android::JavaRef<jobject>& caller, | 37 const base::android::JavaRef<jobject>& caller, |
| 37 jdouble timestamp, | 38 jdouble timestamp, |
| 38 jdouble value1, | 39 jdouble value1, |
| 39 jdouble value2, | 40 jdouble value2, |
| 40 jdouble value3); | 41 jdouble value3); |
| 41 | 42 |
| 42 protected: | 43 protected: |
| 43 ~PlatformSensorAndroid() override; | 44 ~PlatformSensorAndroid() override; |
| 44 bool StartSensor(const PlatformSensorConfiguration& configuration) override; | 45 bool StartSensor(const PlatformSensorConfiguration& configuration) override; |
| 45 void StopSensor() override; | 46 void StopSensor() override; |
| 46 bool CheckSensorConfiguration( | 47 bool CheckSensorConfiguration( |
| 47 const PlatformSensorConfiguration& configuration) override; | 48 const PlatformSensorConfiguration& configuration) override; |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 // Java object org.chromium.device.sensors.PlatformSensor | 51 // Java object org.chromium.device.sensors.PlatformSensor |
| 51 base::android::ScopedJavaGlobalRef<jobject> j_object_; | 52 base::android::ScopedJavaGlobalRef<jobject> j_object_; |
| 52 DISALLOW_COPY_AND_ASSIGN(PlatformSensorAndroid); | 53 DISALLOW_COPY_AND_ASSIGN(PlatformSensorAndroid); |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 } // namespace device | 56 } // namespace device |
| 56 | 57 |
| 57 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_ | 58 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_ |
| OLD | NEW |