SensorInterface.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (C) 2010 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <stdint.h>
  17. #include <sys/types.h>
  18. #include "SensorInterface.h"
  19. namespace android {
  20. // ---------------------------------------------------------------------------
  21. SensorInterface::~SensorInterface()
  22. {
  23. }
  24. // ---------------------------------------------------------------------------
  25. HardwareSensor::HardwareSensor(const sensor_t& sensor)
  26. : mSensorDevice(SensorDevice::getInstance()),
  27. mSensor(&sensor, mSensorDevice.getHalDeviceVersion())
  28. {
  29. }
  30. HardwareSensor::~HardwareSensor() {
  31. }
  32. bool HardwareSensor::process(sensors_event_t* outEvent,
  33. const sensors_event_t& event) {
  34. *outEvent = event;
  35. return true;
  36. }
  37. status_t HardwareSensor::activate(void* ident, bool enabled) {
  38. return mSensorDevice.activate(ident, mSensor.getHandle(), enabled);
  39. }
  40. status_t HardwareSensor::batch(void* ident, int /*handle*/, int flags,
  41. int64_t samplingPeriodNs, int64_t maxBatchReportLatencyNs) {
  42. return mSensorDevice.batch(ident, mSensor.getHandle(), flags, samplingPeriodNs,
  43. maxBatchReportLatencyNs);
  44. }
  45. status_t HardwareSensor::flush(void* ident, int handle) {
  46. return mSensorDevice.flush(ident, handle);
  47. }
  48. status_t HardwareSensor::setDelay(void* ident, int handle, int64_t ns) {
  49. return mSensorDevice.setDelay(ident, handle, ns);
  50. }
  51. void HardwareSensor::autoDisable(void *ident, int handle) {
  52. mSensorDevice.autoDisable(ident, handle);
  53. }
  54. Sensor HardwareSensor::getSensor() const {
  55. return mSensor;
  56. }
  57. // ---------------------------------------------------------------------------
  58. }; // namespace android