blob: f1d16634b5255178d765278a1816421d3d95de65 [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
20#include <cutils/log.h>
21
22#include "SensorInterface.h"
23
24namespace android {
25// ---------------------------------------------------------------------------
26
27SensorInterface::~SensorInterface()
28{
29}
30
31// ---------------------------------------------------------------------------
32
33HardwareSensor::HardwareSensor(const sensor_t& sensor)
34 : mSensorDevice(SensorDevice::getInstance()),
Aravind Akella724d91d2013-06-27 12:04:23 -070035 mSensor(&sensor, mSensorDevice.getHalDeviceVersion())
Mathias Agopianf001c922010-11-11 17:58:51 -080036{
Steve Blockc7839e82012-01-04 20:05:49 +000037 ALOGI("%s", sensor.name);
Mathias Agopianf001c922010-11-11 17:58:51 -080038}
39
40HardwareSensor::~HardwareSensor() {
41}
42
43bool HardwareSensor::process(sensors_event_t* outEvent,
44 const sensors_event_t& event) {
45 *outEvent = event;
46 return true;
47}
48
Mathias Agopian50b66762010-11-29 17:26:51 -080049status_t HardwareSensor::activate(void* ident, bool enabled) {
50 return mSensorDevice.activate(ident, mSensor.getHandle(), enabled);
Mathias Agopianf001c922010-11-11 17:58:51 -080051}
52
Aravind Akella724d91d2013-06-27 12:04:23 -070053status_t HardwareSensor::batch(void* ident, int handle, int flags,
54 int64_t samplingPeriodNs, int64_t maxBatchReportLatencyNs) {
55 return mSensorDevice.batch(ident, mSensor.getHandle(), flags, samplingPeriodNs,
56 maxBatchReportLatencyNs);
57}
58
59status_t HardwareSensor::flush(void* ident, int handle) {
60 return mSensorDevice.flush(ident, handle);
61}
62
Mathias Agopianf001c922010-11-11 17:58:51 -080063status_t HardwareSensor::setDelay(void* ident, int handle, int64_t ns) {
64 return mSensorDevice.setDelay(ident, handle, ns);
65}
66
Mathias Agopianac9a96d2013-07-12 02:01:16 -070067void HardwareSensor::autoDisable(void *ident, int handle) {
68 mSensorDevice.autoDisable(ident, handle);
Jaikumar Ganesh4c01b1a2013-04-16 15:52:23 -070069}
70
Mathias Agopianf001c922010-11-11 17:58:51 -080071Sensor HardwareSensor::getSensor() const {
72 return mSensor;
73}
74
75
76// ---------------------------------------------------------------------------
77}; // namespace android