SensorInterface.cpp revision 0cc8f809924706c7d683da30605f432635dd5bb6
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 20#include "SensorInterface.h" 21 22namespace android { 23// --------------------------------------------------------------------------- 24 25SensorInterface::~SensorInterface() 26{ 27} 28 29// --------------------------------------------------------------------------- 30 31HardwareSensor::HardwareSensor(const sensor_t& sensor) 32 : mSensorDevice(SensorDevice::getInstance()), 33 mSensor(&sensor, mSensorDevice.getHalDeviceVersion()) 34{ 35} 36 37HardwareSensor::~HardwareSensor() { 38} 39 40bool HardwareSensor::process(sensors_event_t* outEvent, 41 const sensors_event_t& event) { 42 *outEvent = event; 43 return true; 44} 45 46status_t HardwareSensor::activate(void* ident, bool enabled) { 47 return mSensorDevice.activate(ident, mSensor.getHandle(), enabled); 48} 49 50status_t HardwareSensor::batch(void* ident, int /*handle*/, int flags, 51 int64_t samplingPeriodNs, int64_t maxBatchReportLatencyNs) { 52 return mSensorDevice.batch(ident, mSensor.getHandle(), flags, samplingPeriodNs, 53 maxBatchReportLatencyNs); 54} 55 56status_t HardwareSensor::flush(void* ident, int handle) { 57 return mSensorDevice.flush(ident, handle); 58} 59 60status_t HardwareSensor::setDelay(void* ident, int handle, int64_t ns) { 61 return mSensorDevice.setDelay(ident, handle, ns); 62} 63 64void HardwareSensor::autoDisable(void *ident, int handle) { 65 mSensorDevice.autoDisable(ident, handle); 66} 67 68const Sensor& HardwareSensor::getSensor() const { 69 return mSensor; 70} 71 72 73// --------------------------------------------------------------------------- 74}; // namespace android 75