blob: 3176462db622b4ba4660a4bf064af6877eca6bce [file] [log] [blame]
Mathias Agopianb957b9d2010-07-13 22:21:56 -07001/*
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_GUI_SENSOR_MANAGER_H
18#define ANDROID_GUI_SENSOR_MANAGER_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
Mathias Agopiande6c44e2011-10-16 22:15:23 -070023#include <binder/IBinder.h>
24
Mathias Agopianb957b9d2010-07-13 22:21:56 -070025#include <utils/Errors.h>
26#include <utils/RefBase.h>
27#include <utils/Singleton.h>
28#include <utils/Vector.h>
29
30#include <gui/SensorEventQueue.h>
31
32// ----------------------------------------------------------------------------
33// Concrete types for the NDK
34struct ASensorManager { };
35
36// ----------------------------------------------------------------------------
37namespace android {
38// ----------------------------------------------------------------------------
39
40class ISensorServer;
41class Sensor;
42class SensorEventQueue;
43
44// ----------------------------------------------------------------------------
45
Mathias Agopiande6c44e2011-10-16 22:15:23 -070046class SensorManager :
47 public ASensorManager,
48 public Singleton<SensorManager>
Mathias Agopianb957b9d2010-07-13 22:21:56 -070049{
50public:
51 SensorManager();
52 ~SensorManager();
53
Mathias Agopian1bf79782010-07-14 23:41:37 -070054 ssize_t getSensorList(Sensor const* const** list) const;
55 Sensor const* getDefaultSensor(int type);
Mathias Agopianb957b9d2010-07-13 22:21:56 -070056 sp<SensorEventQueue> createEventQueue();
57
58private:
Mathias Agopiande6c44e2011-10-16 22:15:23 -070059 // DeathRecipient interface
60 void sensorManagerDied();
61
62 status_t assertStateLocked() const;
63
64private:
65 mutable Mutex mLock;
66 mutable sp<ISensorServer> mSensorServer;
67 mutable Sensor const** mSensorList;
68 mutable Vector<Sensor> mSensors;
69 mutable sp<IBinder::DeathRecipient> mDeathObserver;
Mathias Agopianb957b9d2010-07-13 22:21:56 -070070};
71
72// ----------------------------------------------------------------------------
73}; // namespace android
74
75#endif // ANDROID_GUI_SENSOR_MANAGER_H