platform_sensor_android.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_
  5. #define SERVICES_DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_
  6. #include "base/android/scoped_java_ref.h"
  7. #include "base/memory/ref_counted.h"
  8. #include "services/device/generic_sensor/platform_sensor.h"
  9. namespace device {
  10. class PlatformSensorAndroid : public PlatformSensor {
  11. public:
  12. // Creates a new PlatformSensorAndroid for the given sensor type, returning
  13. // nullptr if it is not supported by the platform.
  14. static scoped_refptr<PlatformSensorAndroid> Create(
  15. mojom::SensorType type,
  16. SensorReadingSharedBuffer* reading_buffer,
  17. PlatformSensorProvider* provider,
  18. const base::android::JavaRef<jobject>& java_provider);
  19. PlatformSensorAndroid(mojom::SensorType type,
  20. SensorReadingSharedBuffer* reading_buffer,
  21. PlatformSensorProvider* provider);
  22. PlatformSensorAndroid(const PlatformSensorAndroid&) = delete;
  23. PlatformSensorAndroid& operator=(const PlatformSensorAndroid&) = delete;
  24. mojom::ReportingMode GetReportingMode() override;
  25. PlatformSensorConfiguration GetDefaultConfiguration() override;
  26. double GetMaximumSupportedFrequency() override;
  27. void NotifyPlatformSensorError(JNIEnv*,
  28. const base::android::JavaRef<jobject>& caller);
  29. void UpdatePlatformSensorReading(
  30. JNIEnv*,
  31. const base::android::JavaRef<jobject>& caller,
  32. jdouble timestamp,
  33. jdouble value1,
  34. jdouble value2,
  35. jdouble value3,
  36. jdouble value4);
  37. protected:
  38. ~PlatformSensorAndroid() override;
  39. bool StartSensor(const PlatformSensorConfiguration& configuration) override;
  40. void StopSensor() override;
  41. bool CheckSensorConfiguration(
  42. const PlatformSensorConfiguration& configuration) override;
  43. private:
  44. // Java object org.chromium.device.sensors.PlatformSensor
  45. base::android::ScopedJavaGlobalRef<jobject> j_object_;
  46. };
  47. } // namespace device
  48. #endif // SERVICES_DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_