1589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian/*
2589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian * Copyright (C) 2010 The Android Open Source Project
3589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian *
4589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
5589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian * you may not use this file except in compliance with the License.
6589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian * You may obtain a copy of the License at
7589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian *
8589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
9589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian *
10589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian * Unless required by applicable law or agreed to in writing, software
11589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
12589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian * See the License for the specific language governing permissions and
14589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian * limitations under the License.
15589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian */
16589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
17589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian#ifndef ANDROID_GUI_SENSOR_H
18589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian#define ANDROID_GUI_SENSOR_H
19589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
20589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian#include <stdint.h>
21589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian#include <sys/types.h>
22589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
23589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian#include <utils/Errors.h>
24589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian#include <utils/Flattenable.h>
25b62013f6aafee08cfad25a2712dc32264e44f783Mathias Agopian#include <utils/String8.h>
26b62013f6aafee08cfad25a2712dc32264e44f783Mathias Agopian#include <utils/Timers.h>
27589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
28589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian#include <hardware/sensors.h>
29589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
30589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian#include <android/sensor.h>
31589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
32589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian// ----------------------------------------------------------------------------
33589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian// Concrete types for the NDK
34589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopianstruct ASensor { };
35589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
36589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian// ----------------------------------------------------------------------------
37589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopiannamespace android {
38589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian// ----------------------------------------------------------------------------
39589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
40589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopianclass Parcel;
41589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
42589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian// ----------------------------------------------------------------------------
43589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
448683fca395d01734ec7946e9f0595ec5d7b754c6Mathias Agopianclass Sensor : public ASensor, public LightFlattenable<Sensor>
45589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian{
46589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopianpublic:
47589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    enum {
48589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian        TYPE_ACCELEROMETER  = ASENSOR_TYPE_ACCELEROMETER,
49589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian        TYPE_MAGNETIC_FIELD = ASENSOR_TYPE_MAGNETIC_FIELD,
50589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian        TYPE_GYROSCOPE      = ASENSOR_TYPE_GYROSCOPE,
51589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian        TYPE_LIGHT          = ASENSOR_TYPE_LIGHT,
52589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian        TYPE_PROXIMITY      = ASENSOR_TYPE_PROXIMITY
53589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    };
54589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
55a7352c9f4a6e642c29782b19db5bc0bd98feddc8Mathias Agopian            Sensor();
56a7352c9f4a6e642c29782b19db5bc0bd98feddc8Mathias Agopian            Sensor(struct sensor_t const* hwSensor);
578683fca395d01734ec7946e9f0595ec5d7b754c6Mathias Agopian            ~Sensor();
58589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
59589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    const String8& getName() const;
60589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    const String8& getVendor() const;
61589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    int32_t getHandle() const;
62589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    int32_t getType() const;
63589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    float getMinValue() const;
64589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    float getMaxValue() const;
65589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    float getResolution() const;
66589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    float getPowerUsage() const;
67a48bcf62b6a26f24a0bdd2b44bb39fadce499e92Mathias Agopian    int32_t getMinDelay() const;
68b62013f6aafee08cfad25a2712dc32264e44f783Mathias Agopian    nsecs_t getMinDelayNs() const;
69b62013f6aafee08cfad25a2712dc32264e44f783Mathias Agopian    int32_t getVersion() const;
70589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
718683fca395d01734ec7946e9f0595ec5d7b754c6Mathias Agopian    // LightFlattenable protocol
728683fca395d01734ec7946e9f0595ec5d7b754c6Mathias Agopian    inline bool isFixedSize() const { return false; }
738683fca395d01734ec7946e9f0595ec5d7b754c6Mathias Agopian    size_t getSize() const;
748683fca395d01734ec7946e9f0595ec5d7b754c6Mathias Agopian    status_t flatten(void* buffer) const;
758683fca395d01734ec7946e9f0595ec5d7b754c6Mathias Agopian    status_t unflatten(void const* buffer, size_t size);
76589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
77589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopianprivate:
78589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    String8 mName;
79589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    String8 mVendor;
80589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    int32_t mHandle;
81589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    int32_t mType;
82589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    float   mMinValue;
83589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    float   mMaxValue;
84589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    float   mResolution;
85589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian    float   mPower;
86a48bcf62b6a26f24a0bdd2b44bb39fadce499e92Mathias Agopian    int32_t mMinDelay;
87b62013f6aafee08cfad25a2712dc32264e44f783Mathias Agopian    int32_t mVersion;
88589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian};
89589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
90589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian// ----------------------------------------------------------------------------
91589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian}; // namespace android
92589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian
93589ce85ee4174829cfedce91b6b2509d2a4002ebMathias Agopian#endif // ANDROID_GUI_SENSOR_H
94