blob: 2de07b1325a9d1ff6e1a03f4bfcc5c4de4e48d5a [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_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
33struct ASensor { };
34
35// ----------------------------------------------------------------------------
36namespace android {
37// ----------------------------------------------------------------------------
38
39class Parcel;
40
41// ----------------------------------------------------------------------------
42
43class Sensor : public ASensor, public Flattenable
44{
45public:
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
Mathias Agopian1bf79782010-07-14 23:41:37 -070054 Sensor();
55 Sensor(struct sensor_t const* hwSensor);
Mathias Agopianb957b9d2010-07-13 22:21:56 -070056 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;
Mathias Agopian050b5622010-07-29 16:51:38 -070066 int32_t getMinDelay() const;
Mathias Agopianb957b9d2010-07-13 22:21:56 -070067
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
76private:
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;
Mathias Agopian050b5622010-07-29 16:51:38 -070085 int32_t mMinDelay;
Mathias Agopianb957b9d2010-07-13 22:21:56 -070086};
87
88// ----------------------------------------------------------------------------
89}; // namespace android
90
91#endif // ANDROID_GUI_SENSOR_H