2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package android.hardware;
21 * Class representing a sensor. Use {@link SensorManager#getSensorList} to get
22 * the list of available Sensors.
25 * @see SensorEventListener
32 * A constant describing an accelerometer sensor type. See
33 * {@link android.hardware.SensorEvent#values SensorEvent.values} for more
36 public static final int TYPE_ACCELEROMETER = 1;
39 * A constant describing a magnetic field sensor type. See
40 * {@link android.hardware.SensorEvent#values SensorEvent.values} for more
43 public static final int TYPE_MAGNETIC_FIELD = 2;
46 * A constant describing an orientation sensor type. See
47 * {@link android.hardware.SensorEvent#values SensorEvent.values} for more
50 * @deprecated use {@link android.hardware.SensorManager#getOrientation
51 * SensorManager.getOrientation()} instead.
54 public static final int TYPE_ORIENTATION = 3;
56 /** A constant describing a gyroscope sensor type */
57 public static final int TYPE_GYROSCOPE = 4;
60 * A constant describing an light sensor type. See
61 * {@link android.hardware.SensorEvent#values SensorEvent.values} for more
64 public static final int TYPE_LIGHT = 5;
66 /** A constant describing a pressure sensor type */
67 public static final int TYPE_PRESSURE = 6;
69 /** A constant describing a temperature sensor type */
70 public static final int TYPE_TEMPERATURE = 7;
73 * A constant describing an proximity sensor type. See
74 * {@link android.hardware.SensorEvent#values SensorEvent.values} for more
77 public static final int TYPE_PROXIMITY = 8;
80 * A constant describing a gravity sensor type.
81 * See {@link android.hardware.SensorEvent SensorEvent}
84 public static final int TYPE_GRAVITY = 9;
87 * A constant describing a linear acceleration sensor type.
88 * See {@link android.hardware.SensorEvent SensorEvent}
91 public static final int TYPE_LINEAR_ACCELERATION = 10;
94 * A constant describing a rotation vector sensor type.
95 * See {@link android.hardware.SensorEvent SensorEvent}
98 public static final int TYPE_ROTATION_VECTOR = 11;
101 * A constant describing all sensor types.
103 public static final int TYPE_ALL = -1;
105 /* Some of these fields are set only by the native bindings in
108 private String mName;
109 private String mVendor;
110 private int mVersion;
113 private float mMaxRange;
114 private float mResolution;
115 private float mPower;
116 private int mMinDelay;
117 private int mLegacyType;
124 * @return name string of the sensor.
126 public String getName() {
131 * @return vendor string of this sensor.
133 public String getVendor() {
138 * @return generic type of this sensor.
140 public int getType() {
145 * @return version of the sensor's module.
147 public int getVersion() {
152 * @return maximum range of the sensor in the sensor's unit.
154 public float getMaximumRange() {
159 * @return resolution of the sensor in the sensor's unit.
161 public float getResolution() {
166 * @return the power in mA used by this sensor while in use
168 public float getPower() {
173 * @return the minimum delay allowed between two events in microsecond
174 * or zero if this sensor only returns a value when the data it's measuring
177 public int getMinDelay() {
185 void setRange(float max, float res) {
190 void setLegacyType(int legacyType) {
191 mLegacyType = legacyType;
194 int getLegacyType() {