blob: 86a16f14f12496fb6ecb0c6d61cdd9e87f27bbd4 [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
54 Sensor();
55 virtual ~Sensor();
56
57 const String8& getName() const;
58 const String8& getVendor() const;
59 int32_t getHandle() const;
60 int32_t getType() const;
61 float getMinValue() const;
62 float getMaxValue() const;
63 float getResolution() const;
64 float getPowerUsage() const;
65
66 // Flattenable interface
67 virtual size_t getFlattenedSize() const;
68 virtual size_t getFdCount() const;
69 virtual status_t flatten(void* buffer, size_t size,
70 int fds[], size_t count) const;
71 virtual status_t unflatten(void const* buffer, size_t size,
72 int fds[], size_t count);
73
74private:
75 String8 mName;
76 String8 mVendor;
77 int32_t mHandle;
78 int32_t mType;
79 float mMinValue;
80 float mMaxValue;
81 float mResolution;
82 float mPower;
83};
84
85// ----------------------------------------------------------------------------
86}; // namespace android
87
88#endif // ANDROID_GUI_SENSOR_H