blob: 970220b291fc608b0d28d4fc60383ffbbcde8809 [file] [log] [blame]
Mathias Agopianf001c922010-11-11 17:58:51 -08001/*
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 Agopianf001c922010-11-11 17:58:51 -080020#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()),
Aravind Akella724d91d2013-06-27 12:04:23 -070033 mSensor(&sensor, mSensorDevice.getHalDeviceVersion())
Mathias Agopianf001c922010-11-11 17:58:51 -080034{
Mathias Agopianf001c922010-11-11 17:58:51 -080035}
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
Mathias Agopian50b66762010-11-29 17:26:51 -080046status_t HardwareSensor::activate(void* ident, bool enabled) {
47 return mSensorDevice.activate(ident, mSensor.getHandle(), enabled);
Mathias Agopianf001c922010-11-11 17:58:51 -080048}
49
Mark Salyzyn92dc3fc2014-03-12 13:12:44 -070050status_t HardwareSensor::batch(void* ident, int /*handle*/, int flags,
Aravind Akella724d91d2013-06-27 12:04:23 -070051 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
Mathias Agopianf001c922010-11-11 17:58:51 -080060status_t HardwareSensor::setDelay(void* ident, int handle, int64_t ns) {
61 return mSensorDevice.setDelay(ident, handle, ns);
62}
63
Mathias Agopianac9a96d2013-07-12 02:01:16 -070064void HardwareSensor::autoDisable(void *ident, int handle) {
65 mSensorDevice.autoDisable(ident, handle);
Jaikumar Ganesh4c01b1a2013-04-16 15:52:23 -070066}
67
Mathias Agopianf001c922010-11-11 17:58:51 -080068Sensor HardwareSensor::getSensor() const {
69 return mSensor;
70}
71
72
73// ---------------------------------------------------------------------------
74}; // namespace android