OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / frameworks / base / services / sensorservice / SensorInterface.h
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 #ifndef ANDROID_SENSOR_INTERFACE_H
18 #define ANDROID_SENSOR_INTERFACE_H
19
20 #include <stdint.h>
21 #include <sys/types.h>
22
23 #include <utils/Singleton.h>
24
25 #include <gui/Sensor.h>
26
27 #include "SensorDevice.h"
28
29 // ---------------------------------------------------------------------------
30
31 namespace android {
32 // ---------------------------------------------------------------------------
33
34 class SensorInterface {
35 public:
36     virtual ~SensorInterface();
37
38     virtual bool process(sensors_event_t* outEvent,
39             const sensors_event_t& event) = 0;
40
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;
45 };
46
47 // ---------------------------------------------------------------------------
48
49 class HardwareSensor : public SensorInterface
50 {
51     SensorDevice& mSensorDevice;
52     Sensor mSensor;
53
54 public:
55     HardwareSensor(const sensor_t& sensor);
56
57     virtual ~HardwareSensor();
58
59     virtual bool process(sensors_event_t* outEvent,
60             const sensors_event_t& event);
61
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; }
66 };
67
68
69 // ---------------------------------------------------------------------------
70 }; // namespace android
71
72 #endif // ANDROID_SENSOR_INTERFACE_H