• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_H
18 #define ANDROID_GUI_SENSOR_H
19 
20 #include <stdint.h>
21 #include <sys/types.h>
22 
23 #include <utils/Errors.h>
24 #include <utils/String8.h>
25 #include <utils/Flattenable.h>
26 
27 #include <hardware/sensors.h>
28 
29 #include <android/sensor.h>
30 
31 // ----------------------------------------------------------------------------
32 // Concrete types for the NDK
33 struct ASensor { };
34 
35 // ----------------------------------------------------------------------------
36 namespace android {
37 // ----------------------------------------------------------------------------
38 
39 class Parcel;
40 
41 // ----------------------------------------------------------------------------
42 
43 class Sensor : public ASensor, public Flattenable
44 {
45 public:
46     enum {
47         TYPE_ACCELEROMETER  = ASENSOR_TYPE_ACCELEROMETER,
48         TYPE_MAGNETIC_FIELD = ASENSOR_TYPE_MAGNETIC_FIELD,
49         TYPE_GYROSCOPE      = ASENSOR_TYPE_GYROSCOPE,
50         TYPE_LIGHT          = ASENSOR_TYPE_LIGHT,
51         TYPE_PROXIMITY      = ASENSOR_TYPE_PROXIMITY
52     };
53 
54             Sensor();
55             Sensor(struct sensor_t const* hwSensor);
56     virtual ~Sensor();
57 
58     const String8& getName() const;
59     const String8& getVendor() const;
60     int32_t getHandle() const;
61     int32_t getType() const;
62     float getMinValue() const;
63     float getMaxValue() const;
64     float getResolution() const;
65     float getPowerUsage() const;
66     int32_t getMinDelay() const;
67 
68     // Flattenable interface
69     virtual size_t getFlattenedSize() const;
70     virtual size_t getFdCount() const;
71     virtual status_t flatten(void* buffer, size_t size,
72             int fds[], size_t count) const;
73     virtual status_t unflatten(void const* buffer, size_t size,
74             int fds[], size_t count);
75 
76 private:
77     String8 mName;
78     String8 mVendor;
79     int32_t mHandle;
80     int32_t mType;
81     float   mMinValue;
82     float   mMaxValue;
83     float   mResolution;
84     float   mPower;
85     int32_t mMinDelay;
86 };
87 
88 // ----------------------------------------------------------------------------
89 }; // namespace android
90 
91 #endif // ANDROID_GUI_SENSOR_H
92