Mathias Agopian | b957b9d | 2010-07-13 22:21:56 -0700 | [diff] [blame] | 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_GUI_SENSOR_MANAGER_H |
| 18 | #define ANDROID_GUI_SENSOR_MANAGER_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Mathias Agopian | de6c44e | 2011-10-16 22:15:23 -0700 | [diff] [blame] | 23 | #include <binder/IBinder.h> |
| 24 | |
Mathias Agopian | b957b9d | 2010-07-13 22:21:56 -0700 | [diff] [blame] | 25 | #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 |
| 34 | struct ASensorManager { }; |
| 35 | |
| 36 | // ---------------------------------------------------------------------------- |
| 37 | namespace android { |
| 38 | // ---------------------------------------------------------------------------- |
| 39 | |
| 40 | class ISensorServer; |
| 41 | class Sensor; |
| 42 | class SensorEventQueue; |
| 43 | |
| 44 | // ---------------------------------------------------------------------------- |
| 45 | |
Mathias Agopian | de6c44e | 2011-10-16 22:15:23 -0700 | [diff] [blame] | 46 | class SensorManager : |
| 47 | public ASensorManager, |
| 48 | public Singleton<SensorManager> |
Mathias Agopian | b957b9d | 2010-07-13 22:21:56 -0700 | [diff] [blame] | 49 | { |
| 50 | public: |
| 51 | SensorManager(); |
| 52 | ~SensorManager(); |
| 53 | |
Mathias Agopian | 1bf7978 | 2010-07-14 23:41:37 -0700 | [diff] [blame] | 54 | ssize_t getSensorList(Sensor const* const** list) const; |
| 55 | Sensor const* getDefaultSensor(int type); |
Mathias Agopian | b957b9d | 2010-07-13 22:21:56 -0700 | [diff] [blame] | 56 | sp<SensorEventQueue> createEventQueue(); |
| 57 | |
| 58 | private: |
Mathias Agopian | de6c44e | 2011-10-16 22:15:23 -0700 | [diff] [blame] | 59 | // DeathRecipient interface |
| 60 | void sensorManagerDied(); |
| 61 | |
| 62 | status_t assertStateLocked() const; |
| 63 | |
| 64 | private: |
| 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 Agopian | b957b9d | 2010-07-13 22:21:56 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | // ---------------------------------------------------------------------------- |
| 73 | }; // namespace android |
| 74 | |
| 75 | #endif // ANDROID_GUI_SENSOR_MANAGER_H |