blob: d0c63d4bc9e2c368936f02b0784d38648d407938 [file] [log] [blame]
Mathias Agopian589ce852010-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 Agopian1a2b83a2011-10-16 22:15:23 -070023#include <binder/IBinder.h>
24
Mathias Agopian589ce852010-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>
Aravind Akella78442202015-03-26 15:58:59 -070029#include <utils/String8.h>
Mathias Agopian589ce852010-07-13 22:21:56 -070030
31#include <gui/SensorEventQueue.h>
32
33// ----------------------------------------------------------------------------
34// Concrete types for the NDK
35struct ASensorManager { };
36
37// ----------------------------------------------------------------------------
38namespace android {
39// ----------------------------------------------------------------------------
40
41class ISensorServer;
42class Sensor;
43class SensorEventQueue;
Mathias Agopian589ce852010-07-13 22:21:56 -070044// ----------------------------------------------------------------------------
45
Mathias Agopian1a2b83a2011-10-16 22:15:23 -070046class SensorManager :
Svetoslavb412f6e2015-04-29 16:50:41 -070047 public ASensorManager
Mathias Agopian589ce852010-07-13 22:21:56 -070048{
49public:
Svetoslavb412f6e2015-04-29 16:50:41 -070050 SensorManager(const String16& opPackageName);
Mathias Agopian589ce852010-07-13 22:21:56 -070051 ~SensorManager();
52
Mathias Agopiana7352c92010-07-14 23:41:37 -070053 ssize_t getSensorList(Sensor const* const** list) const;
54 Sensor const* getDefaultSensor(int type);
Aravind Akellaa9e6cc32015-04-16 18:57:31 -070055 sp<SensorEventQueue> createEventQueue(String8 packageName = String8(""), int mode = 0);
Aravind Akella57952912015-04-24 19:40:50 -070056 status_t enableDataInjection(bool enable);
Mathias Agopian589ce852010-07-13 22:21:56 -070057
58private:
Mathias Agopian1a2b83a2011-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;
Svetoslavb412f6e2015-04-29 16:50:41 -070070 const String16 mOpPackageName;
Mathias Agopian589ce852010-07-13 22:21:56 -070071};
72
73// ----------------------------------------------------------------------------
74}; // namespace android
75
76#endif // ANDROID_GUI_SENSOR_MANAGER_H