2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_SENSOR_INTERFACE_H
18 #define ANDROID_SENSOR_INTERFACE_H
21 #include <sys/types.h>
23 #include <utils/Singleton.h>
25 #include <gui/Sensor.h>
27 #include "SensorDevice.h"
29 // ---------------------------------------------------------------------------
32 // ---------------------------------------------------------------------------
34 class SensorInterface {
36 virtual ~SensorInterface();
38 virtual bool process(sensors_event_t* outEvent,
39 const sensors_event_t& event) = 0;
41 virtual status_t activate(void* ident, bool enabled) = 0;
42 virtual status_t setDelay(void* ident, int handle, int64_t ns) = 0;
43 virtual Sensor getSensor() const = 0;
44 virtual bool isVirtual() const = 0;
47 // ---------------------------------------------------------------------------
49 class HardwareSensor : public SensorInterface
51 SensorDevice& mSensorDevice;
55 HardwareSensor(const sensor_t& sensor);
57 virtual ~HardwareSensor();
59 virtual bool process(sensors_event_t* outEvent,
60 const sensors_event_t& event);
62 virtual status_t activate(void* ident, bool enabled);
63 virtual status_t setDelay(void* ident, int handle, int64_t ns);
64 virtual Sensor getSensor() const;
65 virtual bool isVirtual() const { return false; }
69 // ---------------------------------------------------------------------------
70 }; // namespace android
72 #endif // ANDROID_SENSOR_INTERFACE_H