Mathias Agopian | f001c92 | 2010-11-11 17:58:51 -0800 | [diff] [blame] | 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 | |
| 17 | #include <stdint.h> |
| 18 | #include <sys/types.h> |
| 19 | |
Mathias Agopian | f001c92 | 2010-11-11 17:58:51 -0800 | [diff] [blame] | 20 | #include "SensorInterface.h" |
| 21 | |
| 22 | namespace android { |
| 23 | // --------------------------------------------------------------------------- |
| 24 | |
| 25 | SensorInterface::~SensorInterface() |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | // --------------------------------------------------------------------------- |
| 30 | |
| 31 | HardwareSensor::HardwareSensor(const sensor_t& sensor) |
| 32 | : mSensorDevice(SensorDevice::getInstance()), |
Aravind Akella | 724d91d | 2013-06-27 12:04:23 -0700 | [diff] [blame] | 33 | mSensor(&sensor, mSensorDevice.getHalDeviceVersion()) |
Mathias Agopian | f001c92 | 2010-11-11 17:58:51 -0800 | [diff] [blame] | 34 | { |
Mathias Agopian | f001c92 | 2010-11-11 17:58:51 -0800 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | HardwareSensor::~HardwareSensor() { |
| 38 | } |
| 39 | |
| 40 | bool HardwareSensor::process(sensors_event_t* outEvent, |
| 41 | const sensors_event_t& event) { |
| 42 | *outEvent = event; |
| 43 | return true; |
| 44 | } |
| 45 | |
Mathias Agopian | 50b6676 | 2010-11-29 17:26:51 -0800 | [diff] [blame] | 46 | status_t HardwareSensor::activate(void* ident, bool enabled) { |
| 47 | return mSensorDevice.activate(ident, mSensor.getHandle(), enabled); |
Mathias Agopian | f001c92 | 2010-11-11 17:58:51 -0800 | [diff] [blame] | 48 | } |
| 49 | |
Mark Salyzyn | 92dc3fc | 2014-03-12 13:12:44 -0700 | [diff] [blame] | 50 | status_t HardwareSensor::batch(void* ident, int /*handle*/, int flags, |
Aravind Akella | 724d91d | 2013-06-27 12:04:23 -0700 | [diff] [blame] | 51 | int64_t samplingPeriodNs, int64_t maxBatchReportLatencyNs) { |
| 52 | return mSensorDevice.batch(ident, mSensor.getHandle(), flags, samplingPeriodNs, |
| 53 | maxBatchReportLatencyNs); |
| 54 | } |
| 55 | |
| 56 | status_t HardwareSensor::flush(void* ident, int handle) { |
| 57 | return mSensorDevice.flush(ident, handle); |
| 58 | } |
| 59 | |
Mathias Agopian | f001c92 | 2010-11-11 17:58:51 -0800 | [diff] [blame] | 60 | status_t HardwareSensor::setDelay(void* ident, int handle, int64_t ns) { |
| 61 | return mSensorDevice.setDelay(ident, handle, ns); |
| 62 | } |
| 63 | |
Mathias Agopian | ac9a96d | 2013-07-12 02:01:16 -0700 | [diff] [blame] | 64 | void HardwareSensor::autoDisable(void *ident, int handle) { |
| 65 | mSensorDevice.autoDisable(ident, handle); |
Jaikumar Ganesh | 4c01b1a | 2013-04-16 15:52:23 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Peng Xu | 0cc8f80 | 2016-04-05 23:46:03 -0700 | [diff] [blame] | 68 | const Sensor& HardwareSensor::getSensor() const { |
Mathias Agopian | f001c92 | 2010-11-11 17:58:51 -0800 | [diff] [blame] | 69 | return mSensor; |
| 70 | } |
| 71 | |
| 72 | |
| 73 | // --------------------------------------------------------------------------- |
| 74 | }; // namespace android |