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
23#include <binder/IBinder.h>
24
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
34struct ASensorManager { };
35
36// ----------------------------------------------------------------------------
37namespace android {
38// ----------------------------------------------------------------------------
39
40class ISensorServer;
41class Sensor;
42class SensorEventQueue;
43
44// ----------------------------------------------------------------------------
45
46class SensorManager :
47    public ASensorManager,
48    public Singleton<SensorManager>
49{
50public:
51    SensorManager();
52    ~SensorManager();
53
54    ssize_t getSensorList(Sensor const* const** list) const;
55    Sensor const* getDefaultSensor(int type);
56    sp<SensorEventQueue> createEventQueue();
57
58private:
59    // 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;
70};
71
72// ----------------------------------------------------------------------------
73}; // namespace android
74
75#endif // ANDROID_GUI_SENSOR_MANAGER_H
76