blob: 0c814268157c66db937635404ad5c9e4c06b2568 [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_H
18#define ANDROID_GUI_SENSOR_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <utils/Errors.h>
Mathias Agopian589ce852010-07-13 22:21:56 -070024#include <utils/Flattenable.h>
Mathias Agopianb62013f2011-05-17 22:54:42 -070025#include <utils/String8.h>
26#include <utils/Timers.h>
Mathias Agopian589ce852010-07-13 22:21:56 -070027
28#include <hardware/sensors.h>
29
30#include <android/sensor.h>
31
32// ----------------------------------------------------------------------------
33// Concrete types for the NDK
34struct ASensor { };
35
36// ----------------------------------------------------------------------------
37namespace android {
38// ----------------------------------------------------------------------------
39
40class Parcel;
41
42// ----------------------------------------------------------------------------
43
Mathias Agopian8683fca2012-08-12 19:37:16 -070044class Sensor : public ASensor, public LightFlattenable<Sensor>
Mathias Agopian589ce852010-07-13 22:21:56 -070045{
46public:
47 enum {
48 TYPE_ACCELEROMETER = ASENSOR_TYPE_ACCELEROMETER,
49 TYPE_MAGNETIC_FIELD = ASENSOR_TYPE_MAGNETIC_FIELD,
50 TYPE_GYROSCOPE = ASENSOR_TYPE_GYROSCOPE,
51 TYPE_LIGHT = ASENSOR_TYPE_LIGHT,
52 TYPE_PROXIMITY = ASENSOR_TYPE_PROXIMITY
53 };
54
Mathias Agopiana7352c92010-07-14 23:41:37 -070055 Sensor();
Aravind Akella724d91d2013-06-27 12:04:23 -070056 Sensor(struct sensor_t const* hwSensor, int halVersion = 0);
Mathias Agopian8683fca2012-08-12 19:37:16 -070057 ~Sensor();
Mathias Agopian589ce852010-07-13 22:21:56 -070058
59 const String8& getName() const;
60 const String8& getVendor() const;
61 int32_t getHandle() const;
62 int32_t getType() const;
63 float getMinValue() const;
64 float getMaxValue() const;
65 float getResolution() const;
66 float getPowerUsage() const;
Mathias Agopiana48bcf62010-07-29 16:51:38 -070067 int32_t getMinDelay() const;
Mathias Agopianb62013f2011-05-17 22:54:42 -070068 nsecs_t getMinDelayNs() const;
69 int32_t getVersion() const;
Aravind Akella724d91d2013-06-27 12:04:23 -070070 int32_t getFifoReservedEventCount() const;
71 int32_t getFifoMaxEventCount() const;
Mathias Agopian589ce852010-07-13 22:21:56 -070072
Mathias Agopian8683fca2012-08-12 19:37:16 -070073 // LightFlattenable protocol
74 inline bool isFixedSize() const { return false; }
Mathias Agopiane1424282013-07-29 21:24:40 -070075 size_t getFlattenedSize() const;
76 status_t flatten(void* buffer, size_t size) const;
Mathias Agopian8683fca2012-08-12 19:37:16 -070077 status_t unflatten(void const* buffer, size_t size);
Mathias Agopian589ce852010-07-13 22:21:56 -070078
79private:
80 String8 mName;
81 String8 mVendor;
82 int32_t mHandle;
83 int32_t mType;
84 float mMinValue;
85 float mMaxValue;
86 float mResolution;
87 float mPower;
Mathias Agopiana48bcf62010-07-29 16:51:38 -070088 int32_t mMinDelay;
Mathias Agopianb62013f2011-05-17 22:54:42 -070089 int32_t mVersion;
Aravind Akella724d91d2013-06-27 12:04:23 -070090 int32_t mFifoReservedEventCount;
91 int32_t mFifoMaxEventCount;
Mathias Agopian589ce852010-07-13 22:21:56 -070092};
93
94// ----------------------------------------------------------------------------
95}; // namespace android
96
97#endif // ANDROID_GUI_SENSOR_H