The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
| 18 | package android.hardware; |
| 19 | |
Nick Vaccaro | f5021f6 | 2015-01-23 15:09:45 -0800 | [diff] [blame] | 20 | import android.annotation.SystemApi; |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 21 | import android.os.Build; |
| 22 | |
| 23 | import java.util.UUID; |
Jaikumar Ganesh | 6d0c1d78 | 2013-03-27 17:41:33 -0700 | [diff] [blame] | 24 | |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 25 | /** |
| 26 | * Class representing a sensor. Use {@link SensorManager#getSensorList} to get |
| 27 | * the list of available Sensors. |
Mathias Agopian | 0f791a7 | 2010-06-22 21:55:01 -0700 | [diff] [blame] | 28 | * |
| 29 | * @see SensorManager |
| 30 | * @see SensorEventListener |
| 31 | * @see SensorEvent |
| 32 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | */ |
Jeff Brown | 6a2ef12 | 2012-08-10 18:19:10 -0700 | [diff] [blame] | 34 | public final class Sensor { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 36 | /** |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 37 | * A constant describing an accelerometer sensor type. |
| 38 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
| 39 | * for more details. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | */ |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 41 | public static final int TYPE_ACCELEROMETER = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 43 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 44 | * A constant string describing an accelerometer sensor type. |
| 45 | * |
| 46 | * @see #TYPE_ACCELEROMETER |
| 47 | */ |
| 48 | public static final String STRING_TYPE_ACCELEROMETER = "android.sensor.accelerometer"; |
| 49 | |
| 50 | /** |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 51 | * A constant describing a magnetic field sensor type. |
| 52 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
| 53 | * for more details. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | */ |
| 55 | public static final int TYPE_MAGNETIC_FIELD = 2; |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 56 | |
| 57 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 58 | * A constant string describing a magnetic field sensor type. |
| 59 | * |
| 60 | * @see #TYPE_MAGNETIC_FIELD |
| 61 | */ |
| 62 | public static final String STRING_TYPE_MAGNETIC_FIELD = "android.sensor.magnetic_field"; |
| 63 | |
| 64 | /** |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 65 | * A constant describing an orientation sensor type. |
| 66 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
| 67 | * for more details. |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 68 | * |
Mathias Agopian | 61a4493 | 2010-02-26 18:06:26 -0800 | [diff] [blame] | 69 | * @deprecated use {@link android.hardware.SensorManager#getOrientation |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 70 | * SensorManager.getOrientation()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | */ |
Mathias Agopian | 61a4493 | 2010-02-26 18:06:26 -0800 | [diff] [blame] | 72 | @Deprecated |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 73 | public static final int TYPE_ORIENTATION = 3; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 75 | /** |
| 76 | * A constant string describing an orientation sensor type. |
| 77 | * |
| 78 | * @see #TYPE_ORIENTATION |
| 79 | * @deprecated use {@link android.hardware.SensorManager#getOrientation |
| 80 | * SensorManager.getOrientation()} instead. |
| 81 | */ |
| 82 | @Deprecated |
| 83 | public static final String STRING_TYPE_ORIENTATION = "android.sensor.orientation"; |
| 84 | |
| 85 | /** |
| 86 | * A constant describing a gyroscope sensor type. |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 87 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
| 88 | * for more details. */ |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 89 | public static final int TYPE_GYROSCOPE = 4; |
| 90 | |
Mike Lockwood | 4115c51 | 2009-11-03 10:35:43 -0500 | [diff] [blame] | 91 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 92 | * A constant string describing a gyroscope sensor type. |
| 93 | * |
| 94 | * @see #TYPE_GYROSCOPE |
| 95 | */ |
| 96 | public static final String STRING_TYPE_GYROSCOPE = "android.sensor.gyroscope"; |
| 97 | |
| 98 | /** |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 99 | * A constant describing a light sensor type. |
| 100 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
| 101 | * for more details. |
Mike Lockwood | 4115c51 | 2009-11-03 10:35:43 -0500 | [diff] [blame] | 102 | */ |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 103 | public static final int TYPE_LIGHT = 5; |
Mathias Agopian | 210fc91 | 2010-02-26 13:51:39 -0800 | [diff] [blame] | 104 | |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 105 | /** |
| 106 | * A constant string describing a light sensor type. |
| 107 | * |
| 108 | * @see #TYPE_LIGHT |
| 109 | */ |
| 110 | public static final String STRING_TYPE_LIGHT = "android.sensor.light"; |
| 111 | |
| 112 | /** |
| 113 | * A constant describing a pressure sensor type. |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 114 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 115 | * for more details. |
| 116 | */ |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 117 | public static final int TYPE_PRESSURE = 6; |
Mathias Agopian | 210fc91 | 2010-02-26 13:51:39 -0800 | [diff] [blame] | 118 | |
Mathias Agopian | 462db22 | 2011-03-22 18:44:26 -0700 | [diff] [blame] | 119 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 120 | * A constant string describing a pressure sensor type. |
| 121 | * |
| 122 | * @see #TYPE_PRESSURE |
| 123 | */ |
| 124 | public static final String STRING_TYPE_PRESSURE = "android.sensor.pressure"; |
| 125 | |
| 126 | /** |
Mathias Agopian | 462db22 | 2011-03-22 18:44:26 -0700 | [diff] [blame] | 127 | * A constant describing a temperature sensor type |
| 128 | * |
| 129 | * @deprecated use |
| 130 | * {@link android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE |
| 131 | * Sensor.TYPE_AMBIENT_TEMPERATURE} instead. |
| 132 | */ |
| 133 | @Deprecated |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 134 | public static final int TYPE_TEMPERATURE = 7; |
Mathias Agopian | 210fc91 | 2010-02-26 13:51:39 -0800 | [diff] [blame] | 135 | |
Mike Lockwood | 4115c51 | 2009-11-03 10:35:43 -0500 | [diff] [blame] | 136 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 137 | * A constant string describing a temperature sensor type |
| 138 | * |
| 139 | * @see #TYPE_TEMPERATURE |
| 140 | * @deprecated use |
| 141 | * {@link android.hardware.Sensor#STRING_TYPE_AMBIENT_TEMPERATURE |
| 142 | * Sensor.STRING_TYPE_AMBIENT_TEMPERATURE} instead. |
| 143 | */ |
| 144 | @Deprecated |
| 145 | public static final String STRING_TYPE_TEMPERATURE = "android.sensor.temperature"; |
| 146 | |
| 147 | /** |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 148 | * A constant describing a proximity sensor type. This is a wake up sensor. |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 149 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
| 150 | * for more details. |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 151 | * @see #isWakeUpSensor() |
Mike Lockwood | 4115c51 | 2009-11-03 10:35:43 -0500 | [diff] [blame] | 152 | */ |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 153 | public static final int TYPE_PROXIMITY = 8; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 154 | |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 155 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 156 | * A constant string describing a proximity sensor type. |
| 157 | * |
| 158 | * @see #TYPE_PROXIMITY |
| 159 | */ |
| 160 | public static final String STRING_TYPE_PROXIMITY = "android.sensor.proximity"; |
| 161 | |
| 162 | /** |
Kevin Powell | f35fd95 | 2010-07-19 19:10:40 -0700 | [diff] [blame] | 163 | * A constant describing a gravity sensor type. |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 164 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
Kevin Powell | f35fd95 | 2010-07-19 19:10:40 -0700 | [diff] [blame] | 165 | * for more details. |
| 166 | */ |
| 167 | public static final int TYPE_GRAVITY = 9; |
| 168 | |
| 169 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 170 | * A constant string describing a gravity sensor type. |
| 171 | * |
| 172 | * @see #TYPE_GRAVITY |
| 173 | */ |
| 174 | public static final String STRING_TYPE_GRAVITY = "android.sensor.gravity"; |
| 175 | |
| 176 | /** |
Kevin Powell | f35fd95 | 2010-07-19 19:10:40 -0700 | [diff] [blame] | 177 | * A constant describing a linear acceleration sensor type. |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 178 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
Kevin Powell | f35fd95 | 2010-07-19 19:10:40 -0700 | [diff] [blame] | 179 | * for more details. |
| 180 | */ |
| 181 | public static final int TYPE_LINEAR_ACCELERATION = 10; |
| 182 | |
| 183 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 184 | * A constant string describing a linear acceleration sensor type. |
| 185 | * |
| 186 | * @see #TYPE_LINEAR_ACCELERATION |
| 187 | */ |
| 188 | public static final String STRING_TYPE_LINEAR_ACCELERATION = |
| 189 | "android.sensor.linear_acceleration"; |
| 190 | |
| 191 | /** |
Kevin Powell | f35fd95 | 2010-07-19 19:10:40 -0700 | [diff] [blame] | 192 | * A constant describing a rotation vector sensor type. |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 193 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
Kevin Powell | f35fd95 | 2010-07-19 19:10:40 -0700 | [diff] [blame] | 194 | * for more details. |
| 195 | */ |
| 196 | public static final int TYPE_ROTATION_VECTOR = 11; |
| 197 | |
Urs Fleisch | 5819051 | 2010-12-29 17:02:02 +0100 | [diff] [blame] | 198 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 199 | * A constant string describing a rotation vector sensor type. |
| 200 | * |
| 201 | * @see #TYPE_ROTATION_VECTOR |
| 202 | */ |
| 203 | public static final String STRING_TYPE_ROTATION_VECTOR = "android.sensor.rotation_vector"; |
| 204 | |
| 205 | /** |
Urs Fleisch | 5819051 | 2010-12-29 17:02:02 +0100 | [diff] [blame] | 206 | * A constant describing a relative humidity sensor type. |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 207 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
Urs Fleisch | 5819051 | 2010-12-29 17:02:02 +0100 | [diff] [blame] | 208 | * for more details. |
| 209 | */ |
| 210 | public static final int TYPE_RELATIVE_HUMIDITY = 12; |
| 211 | |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 212 | /** |
| 213 | * A constant string describing a relative humidity sensor type |
| 214 | * |
| 215 | * @see #TYPE_RELATIVE_HUMIDITY |
| 216 | */ |
| 217 | public static final String STRING_TYPE_RELATIVE_HUMIDITY = "android.sensor.relative_humidity"; |
| 218 | |
| 219 | /** |
| 220 | * A constant describing an ambient temperature sensor type. |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 221 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 222 | * for more details. |
| 223 | */ |
Mathias Agopian | 462db22 | 2011-03-22 18:44:26 -0700 | [diff] [blame] | 224 | public static final int TYPE_AMBIENT_TEMPERATURE = 13; |
| 225 | |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 226 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 227 | * A constant string describing an ambient temperature sensor type. |
| 228 | * |
| 229 | * @see #TYPE_AMBIENT_TEMPERATURE |
| 230 | */ |
| 231 | public static final String STRING_TYPE_AMBIENT_TEMPERATURE = |
| 232 | "android.sensor.ambient_temperature"; |
| 233 | |
| 234 | /** |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 235 | * A constant describing an uncalibrated magnetic field sensor type. |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 236 | * <p> |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 237 | * Similar to {@link #TYPE_MAGNETIC_FIELD} but the hard iron calibration (device calibration |
| 238 | * due to distortions that arise from magnetized iron, steel or permanent magnets on the |
| 239 | * device) is not considered in the given sensor values. However, such hard iron bias values |
| 240 | * are returned to you separately in the result {@link android.hardware.SensorEvent#values} |
Aravind Akella | 4b628cb | 2013-08-05 18:43:55 -0700 | [diff] [blame] | 241 | * so you may use them for custom calibrations. |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 242 | * <p>Also, no periodic calibration is performed |
| 243 | * (i.e. there are no discontinuities in the data stream while using this sensor) and |
| 244 | * assumptions that the magnetic field is due to the Earth's poles is avoided, but |
| 245 | * factory calibration and temperature compensation have been performed. |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 246 | * </p> |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 247 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} for more |
| 248 | * details. |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 249 | */ |
| 250 | public static final int TYPE_MAGNETIC_FIELD_UNCALIBRATED = 14; |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 251 | /** |
| 252 | * A constant string describing an uncalibrated magnetic field sensor type. |
| 253 | * |
| 254 | * @see #TYPE_MAGNETIC_FIELD_UNCALIBRATED |
| 255 | */ |
| 256 | public static final String STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED = |
| 257 | "android.sensor.magnetic_field_uncalibrated"; |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 258 | |
| 259 | /** |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 260 | * A constant describing an uncalibrated rotation vector sensor type. |
| 261 | * <p>Identical to {@link #TYPE_ROTATION_VECTOR} except that it doesn't |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 262 | * use the geomagnetic field. Therefore the Y axis doesn't |
| 263 | * point north, but instead to some other reference, that reference is |
| 264 | * allowed to drift by the same order of magnitude as the gyroscope |
| 265 | * drift around the Z axis. |
| 266 | * <p> |
| 267 | * In the ideal case, a phone rotated and returning to the same real-world |
| 268 | * orientation should report the same game rotation vector |
| 269 | * (without using the earth's geomagnetic field). However, the orientation |
| 270 | * may drift somewhat over time. |
| 271 | * </p> |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 272 | * <p>See {@link android.hardware.SensorEvent#values SensorEvent.values} for more |
| 273 | * details. |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 274 | */ |
Etienne Le Grand | 819239e | 2014-04-05 04:47:14 +0000 | [diff] [blame] | 275 | public static final int TYPE_GAME_ROTATION_VECTOR = 15; |
Etienne Le Grand | fd53d83 | 2014-03-24 21:29:28 -0700 | [diff] [blame] | 276 | |
| 277 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 278 | * A constant string describing an uncalibrated rotation vector sensor type. |
| 279 | * |
| 280 | * @see #TYPE_GAME_ROTATION_VECTOR |
| 281 | */ |
| 282 | public static final String STRING_TYPE_GAME_ROTATION_VECTOR = |
| 283 | "android.sensor.game_rotation_vector"; |
| 284 | |
| 285 | /** |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 286 | * A constant describing an uncalibrated gyroscope sensor type. |
| 287 | * <p>Similar to {@link #TYPE_GYROSCOPE} but no gyro-drift compensation has been performed |
| 288 | * to adjust the given sensor values. However, such gyro-drift bias values |
| 289 | * are returned to you separately in the result {@link android.hardware.SensorEvent#values} |
| 290 | * so you may use them for custom calibrations. |
| 291 | * <p>Factory calibration and temperature compensation is still applied |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 292 | * to the rate of rotation (angular speeds). |
| 293 | * </p> |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 294 | * <p> See {@link android.hardware.SensorEvent#values SensorEvent.values} for more |
| 295 | * details. |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 296 | */ |
| 297 | public static final int TYPE_GYROSCOPE_UNCALIBRATED = 16; |
| 298 | |
| 299 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 300 | * A constant string describing an uncalibrated gyroscope sensor type. |
| 301 | * |
| 302 | * @see #TYPE_GYROSCOPE_UNCALIBRATED |
| 303 | */ |
| 304 | public static final String STRING_TYPE_GYROSCOPE_UNCALIBRATED = |
| 305 | "android.sensor.gyroscope_uncalibrated"; |
| 306 | |
| 307 | /** |
Aravind Akella | 4b628cb | 2013-08-05 18:43:55 -0700 | [diff] [blame] | 308 | * A constant describing a significant motion trigger sensor. |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 309 | * <p> |
| 310 | * It triggers when an event occurs and then automatically disables |
| 311 | * itself. The sensor continues to operate while the device is asleep |
| 312 | * and will automatically wake the device to notify when significant |
| 313 | * motion is detected. The application does not need to hold any wake |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 314 | * locks for this sensor to trigger. This is a wake up sensor. |
Scott Main | 92053f8 | 2013-06-13 16:32:50 -0700 | [diff] [blame] | 315 | * <p>See {@link TriggerEvent} for more details. |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 316 | * |
| 317 | * @see #isWakeUpSensor() |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 318 | */ |
| 319 | public static final int TYPE_SIGNIFICANT_MOTION = 17; |
| 320 | |
| 321 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 322 | * A constant string describing a significant motion trigger sensor. |
| 323 | * |
| 324 | * @see #TYPE_SIGNIFICANT_MOTION |
| 325 | */ |
| 326 | public static final String STRING_TYPE_SIGNIFICANT_MOTION = |
| 327 | "android.sensor.significant_motion"; |
| 328 | |
| 329 | /** |
Aravind Akella | 4b628cb | 2013-08-05 18:43:55 -0700 | [diff] [blame] | 330 | * A constant describing a step detector sensor. |
| 331 | * <p> |
| 332 | * A sensor of this type triggers an event each time a step is taken by the user. The only |
| 333 | * allowed value to return is 1.0 and an event is generated for each step. Like with any other |
| 334 | * event, the timestamp indicates when the event (here the step) occurred, this corresponds to |
Aravind Akella | 1f9b32f | 2014-09-16 15:21:44 -0700 | [diff] [blame] | 335 | * when the foot hit the ground, generating a high variation in acceleration. This sensor is |
| 336 | * only for detecting every individual step as soon as it is taken, for example to perform dead |
| 337 | * reckoning. If you only need aggregate number of steps taken over a period of time, register |
| 338 | * for {@link #TYPE_STEP_COUNTER} instead. It is defined as a |
| 339 | * {@link Sensor#REPORTING_MODE_SPECIAL_TRIGGER} sensor. |
Aravind Akella | 4b628cb | 2013-08-05 18:43:55 -0700 | [diff] [blame] | 340 | * <p> |
| 341 | * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details. |
| 342 | */ |
| 343 | public static final int TYPE_STEP_DETECTOR = 18; |
| 344 | |
| 345 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 346 | * A constant string describing a step detector sensor. |
| 347 | * |
| 348 | * @see #TYPE_STEP_DETECTOR |
| 349 | */ |
| 350 | public static final String STRING_TYPE_STEP_DETECTOR = "android.sensor.step_detector"; |
| 351 | |
| 352 | /** |
Aravind Akella | 4b628cb | 2013-08-05 18:43:55 -0700 | [diff] [blame] | 353 | * A constant describing a step counter sensor. |
| 354 | * <p> |
| 355 | * A sensor of this type returns the number of steps taken by the user since the last reboot |
| 356 | * while activated. The value is returned as a float (with the fractional part set to zero) and |
| 357 | * is reset to zero only on a system reboot. The timestamp of the event is set to the time when |
Aravind Akella | 0c44d69 | 2014-08-19 18:28:12 -0700 | [diff] [blame] | 358 | * the last step for that event was taken. This sensor is implemented in hardware and is |
Aravind Akella | 1f9b32f | 2014-09-16 15:21:44 -0700 | [diff] [blame] | 359 | * expected to be low power. If you want to continuously track the number of steps over a long |
| 360 | * period of time, do NOT unregister for this sensor, so that it keeps counting steps in the |
| 361 | * background even when the AP is in suspend mode and report the aggregate count when the AP |
| 362 | * is awake. Application needs to stay registered for this sensor because step counter does not |
| 363 | * count steps if it is not activated. This sensor is ideal for fitness tracking applications. |
| 364 | * It is defined as an {@link Sensor#REPORTING_MODE_ON_CHANGE} sensor. |
Aravind Akella | 4b628cb | 2013-08-05 18:43:55 -0700 | [diff] [blame] | 365 | * <p> |
| 366 | * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details. |
| 367 | */ |
| 368 | public static final int TYPE_STEP_COUNTER = 19; |
| 369 | |
| 370 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 371 | * A constant string describing a step counter sensor. |
| 372 | * |
| 373 | * @see #TYPE_STEP_COUNTER |
| 374 | */ |
| 375 | public static final String STRING_TYPE_STEP_COUNTER = "android.sensor.step_counter"; |
| 376 | |
| 377 | /** |
| 378 | * A constant describing a geo-magnetic rotation vector. |
Aravind Akella | 4b628cb | 2013-08-05 18:43:55 -0700 | [diff] [blame] | 379 | * <p> |
Aravind Akella | f0f4a83 | 2013-08-07 20:05:29 -0700 | [diff] [blame] | 380 | * Similar to {@link #TYPE_ROTATION_VECTOR}, but using a magnetometer instead of using a |
Aravind Akella | 4b628cb | 2013-08-05 18:43:55 -0700 | [diff] [blame] | 381 | * gyroscope. This sensor uses lower power than the other rotation vectors, because it doesn't |
| 382 | * use the gyroscope. However, it is more noisy and will work best outdoors. |
| 383 | * <p> |
| 384 | * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details. |
| 385 | */ |
| 386 | public static final int TYPE_GEOMAGNETIC_ROTATION_VECTOR = 20; |
| 387 | |
| 388 | /** |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 389 | * A constant string describing a geo-magnetic rotation vector. |
| 390 | * |
| 391 | * @see #TYPE_GEOMAGNETIC_ROTATION_VECTOR |
| 392 | */ |
| 393 | public static final String STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR = |
| 394 | "android.sensor.geomagnetic_rotation_vector"; |
| 395 | |
| 396 | /** |
| 397 | * A constant describing a heart rate monitor. |
| 398 | * <p> |
Etienne Le Grand | af80510 | 2014-05-16 12:21:41 -0700 | [diff] [blame] | 399 | * The reported value is the heart rate in beats per minute. |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 400 | * <p> |
Etienne Le Grand | af80510 | 2014-05-16 12:21:41 -0700 | [diff] [blame] | 401 | * The reported accuracy represents the status of the monitor during the reading. See the |
| 402 | * {@code SENSOR_STATUS_*} constants in {@link android.hardware.SensorManager SensorManager} |
| 403 | * for more details on accuracy/status values. In particular, when the accuracy is |
| 404 | * {@code SENSOR_STATUS_UNRELIABLE} or {@code SENSOR_STATUS_NO_CONTACT}, the heart rate |
| 405 | * value should be discarded. |
| 406 | * <p> |
| 407 | * This sensor requires permission {@code android.permission.BODY_SENSORS}. |
| 408 | * It will not be returned by {@code SensorManager.getSensorsList} nor |
| 409 | * {@code SensorManager.getDefaultSensor} if the application doesn't have this permission. |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 410 | */ |
| 411 | public static final int TYPE_HEART_RATE = 21; |
| 412 | |
| 413 | /** |
| 414 | * A constant string describing a heart rate monitor. |
| 415 | * |
| 416 | * @see #TYPE_HEART_RATE |
| 417 | */ |
| 418 | public static final String STRING_TYPE_HEART_RATE = "android.sensor.heart_rate"; |
| 419 | |
| 420 | /** |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 421 | * A sensor of this type generates an event each time a tilt event is detected. A tilt event |
| 422 | * is generated if the direction of the 2-seconds window average gravity changed by at |
| 423 | * least 35 degrees since the activation of the sensor. It is a wake up sensor. |
| 424 | * |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 425 | * @hide |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 426 | * @see #isWakeUpSensor() |
| 427 | */ |
Aravind Akella | 0288ca6 | 2014-07-28 14:53:44 -0700 | [diff] [blame] | 428 | public static final int TYPE_TILT_DETECTOR = 22; |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 429 | |
| 430 | /** |
| 431 | * A constant string describing a wake up tilt detector sensor type. |
| 432 | * |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 433 | * @hide |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 434 | * @see #TYPE_WAKE_UP_TILT_DETECTOR |
| 435 | */ |
Aravind Akella | 0288ca6 | 2014-07-28 14:53:44 -0700 | [diff] [blame] | 436 | public static final String SENSOR_STRING_TYPE_TILT_DETECTOR = |
| 437 | "android.sensor.tilt_detector"; |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 438 | |
| 439 | /** |
Etienne Le Grand | 28071e3 | 2014-05-07 19:47:43 -0700 | [diff] [blame] | 440 | * A constant describing a wake gesture sensor. |
| 441 | * <p> |
| 442 | * Wake gesture sensors enable waking up the device based on a device specific motion. |
| 443 | * <p> |
| 444 | * When this sensor triggers, the device behaves as if the power button was pressed, turning the |
| 445 | * screen on. This behavior (turning on the screen when this sensor triggers) might be |
| 446 | * deactivated by the user in the device settings. Changes in settings do not impact the |
| 447 | * behavior of the sensor: only whether the framework turns the screen on when it triggers. |
| 448 | * <p> |
| 449 | * The actual gesture to be detected is not specified, and can be chosen by the manufacturer of |
| 450 | * the device. This sensor must be low power, as it is likely to be activated 24/7. |
| 451 | * Values of events created by this sensors should not be used. |
| 452 | * |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 453 | * @see #isWakeUpSensor() |
Jeff Brown | 241e70d | 2014-07-17 15:12:37 -0700 | [diff] [blame] | 454 | * @hide This sensor is expected to only be used by the system ui |
Etienne Le Grand | 28071e3 | 2014-05-07 19:47:43 -0700 | [diff] [blame] | 455 | */ |
Aravind Akella | 0288ca6 | 2014-07-28 14:53:44 -0700 | [diff] [blame] | 456 | public static final int TYPE_WAKE_GESTURE = 23; |
Etienne Le Grand | 28071e3 | 2014-05-07 19:47:43 -0700 | [diff] [blame] | 457 | |
| 458 | /** |
| 459 | * A constant string describing a wake gesture sensor. |
| 460 | * |
Jeff Brown | 241e70d | 2014-07-17 15:12:37 -0700 | [diff] [blame] | 461 | * @hide This sensor is expected to only be used by the system ui |
Etienne Le Grand | 28071e3 | 2014-05-07 19:47:43 -0700 | [diff] [blame] | 462 | * @see #TYPE_WAKE_GESTURE |
| 463 | */ |
| 464 | public static final String STRING_TYPE_WAKE_GESTURE = "android.sensor.wake_gesture"; |
| 465 | |
| 466 | /** |
Jeff Brown | 241e70d | 2014-07-17 15:12:37 -0700 | [diff] [blame] | 467 | * A constant describing a wake gesture sensor. |
| 468 | * <p> |
| 469 | * A sensor enabling briefly turning the screen on to enable the user to |
| 470 | * glance content on screen based on a specific motion. The device should |
| 471 | * turn the screen off after a few moments. |
| 472 | * <p> |
| 473 | * When this sensor triggers, the device turns the screen on momentarily |
| 474 | * to allow the user to glance notifications or other content while the |
| 475 | * device remains locked in a non-interactive state (dozing). This behavior |
| 476 | * (briefly turning on the screen when this sensor triggers) might be deactivated |
| 477 | * by the user in the device settings. Changes in settings do not impact the |
| 478 | * behavior of the sensor: only whether the framework briefly turns the screen on |
| 479 | * when it triggers. |
| 480 | * <p> |
| 481 | * The actual gesture to be detected is not specified, and can be chosen by the manufacturer of |
| 482 | * the device. This sensor must be low power, as it is likely to be activated 24/7. |
| 483 | * Values of events created by this sensors should not be used. |
| 484 | * |
| 485 | * @see #isWakeUpSensor() |
| 486 | * @hide This sensor is expected to only be used by the system ui |
| 487 | */ |
Aravind Akella | 0288ca6 | 2014-07-28 14:53:44 -0700 | [diff] [blame] | 488 | public static final int TYPE_GLANCE_GESTURE = 24; |
Jeff Brown | 241e70d | 2014-07-17 15:12:37 -0700 | [diff] [blame] | 489 | |
| 490 | /** |
| 491 | * A constant string describing a wake gesture sensor. |
| 492 | * |
| 493 | * @hide This sensor is expected to only be used by the system ui |
| 494 | * @see #TYPE_GLANCE_GESTURE |
| 495 | */ |
| 496 | public static final String STRING_TYPE_GLANCE_GESTURE = "android.sensor.glance_gesture"; |
| 497 | |
Aravind Akella | 96eb62c | 2014-07-17 12:42:00 -0700 | [diff] [blame] | 498 | /** |
| 499 | * A constant describing a pick up sensor. |
| 500 | * |
| 501 | * A sensor of this type triggers when the device is picked up regardless of wherever it was |
| 502 | * before (desk, pocket, bag). The only allowed return value is 1.0. This sensor deactivates |
| 503 | * itself immediately after it triggers. |
| 504 | * |
| 505 | * @hide Expected to be used internally for always on display. |
| 506 | */ |
Aravind Akella | 0288ca6 | 2014-07-28 14:53:44 -0700 | [diff] [blame] | 507 | public static final int TYPE_PICK_UP_GESTURE = 25; |
Aravind Akella | 96eb62c | 2014-07-17 12:42:00 -0700 | [diff] [blame] | 508 | |
| 509 | /** |
| 510 | * A constant string describing a pick up sensor. |
| 511 | * |
| 512 | * @hide This sensor is expected to be used internally for always on display. |
| 513 | * @see #TYPE_PICK_UP_GESTURE |
| 514 | */ |
| 515 | public static final String STRING_TYPE_PICK_UP_GESTURE = "android.sensor.pick_up_gesture"; |
| 516 | |
Nick Vaccaro | f5021f6 | 2015-01-23 15:09:45 -0800 | [diff] [blame] | 517 | /** |
| 518 | * A constant describing a wrist tilt gesture sensor. |
| 519 | * |
| 520 | * A sensor of this type triggers when the device face is tilted towards the user. |
| 521 | * The only allowed return value is 1.0. |
| 522 | * This sensor remains active until disabled. |
| 523 | * |
| 524 | * @hide This sensor is expected to only be used by the system ui |
| 525 | */ |
| 526 | @SystemApi |
| 527 | public static final int TYPE_WRIST_TILT_GESTURE = 26; |
| 528 | |
| 529 | /** |
| 530 | * A constant string describing a wrist tilt gesture sensor. |
| 531 | * |
| 532 | * @hide This sensor is expected to only be used by the system ui |
| 533 | * @see #TYPE_WRIST_TILT_GESTURE |
| 534 | */ |
| 535 | @SystemApi |
| 536 | public static final String STRING_TYPE_WRIST_TILT_GESTURE = "android.sensor.wrist_tilt_gesture"; |
| 537 | |
Jeff Brown | 241e70d | 2014-07-17 15:12:37 -0700 | [diff] [blame] | 538 | /** |
Trevor Bunker | 3c288e6 | 2016-01-08 11:11:13 -0800 | [diff] [blame] | 539 | * The current orientation of the device. |
| 540 | * <p> |
| 541 | * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details. |
| 542 | * |
| 543 | * @hide Expected to be used internally for auto-rotate and speaker rotation. |
| 544 | * |
| 545 | */ |
| 546 | public static final int TYPE_DEVICE_ORIENTATION = 27; |
| 547 | |
| 548 | /** |
| 549 | * A constant string describing a device orientation sensor type. |
| 550 | * |
| 551 | * @hide |
| 552 | * @see #TYPE_DEVICE_ORIENTATION |
| 553 | */ |
| 554 | public static final String STRING_TYPE_DEVICE_ORIENTATION = "android.sensor.device_orientation"; |
| 555 | |
Ashutosh Joshi | 17efe02 | 2016-01-14 22:23:58 -0800 | [diff] [blame] | 556 | /** |
| 557 | * A constant describing a pose sensor with 6 degrees of freedom. |
| 558 | * |
| 559 | * Similar to {@link #TYPE_ROTATION_VECTOR}, with additional delta |
| 560 | * translation from an arbitrary reference point. |
| 561 | * |
Ashutosh Joshi | af1a266 | 2016-01-25 20:24:20 -0800 | [diff] [blame] | 562 | * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details. |
| 563 | * |
Ashutosh Joshi | 17efe02 | 2016-01-14 22:23:58 -0800 | [diff] [blame] | 564 | * Can use camera, depth sensor etc to compute output value. |
| 565 | * |
| 566 | * This is expected to be a high power sensor and expected only to be |
| 567 | * used when the screen is on. |
| 568 | * |
| 569 | * Expected to be more accurate than the rotation vector alone. |
| 570 | * |
| 571 | */ |
| 572 | public static final int TYPE_POSE_6DOF = 28; |
| 573 | |
| 574 | /** |
| 575 | * A constant string describing a pose sensor with 6 degrees of freedom. |
| 576 | * |
| 577 | * @see #TYPE_POSE_6DOF |
| 578 | */ |
| 579 | public static final String STRING_TYPE_POSE_6DOF = "android.sensor.pose_6dof"; |
| 580 | |
Ashutosh Joshi | af1a266 | 2016-01-25 20:24:20 -0800 | [diff] [blame] | 581 | /** |
| 582 | * A constant describing a stationary detect sensor. |
| 583 | * |
| 584 | * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details. |
| 585 | * |
| 586 | */ |
| 587 | public static final int TYPE_STATIONARY_DETECT = 29; |
| 588 | |
| 589 | /** |
| 590 | * A constant string describing a stationary detection sensor. |
| 591 | * |
| 592 | * @see #TYPE_STATIONARY_DETECT |
| 593 | */ |
| 594 | public static final String STRING_TYPE_STATIONARY_DETECT = "android.sensor.stationary_detect"; |
| 595 | |
| 596 | /** |
| 597 | * A constant describing a motion detect sensor. |
| 598 | * |
| 599 | * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details. |
| 600 | * |
| 601 | */ |
| 602 | public static final int TYPE_MOTION_DETECT = 30; |
| 603 | |
| 604 | /** |
| 605 | * A constant string describing a motion detection sensor. |
| 606 | * |
| 607 | * @see #TYPE_MOTION_DETECT |
| 608 | */ |
| 609 | public static final String STRING_TYPE_MOTION_DETECT = "android.sensor.motion_detect"; |
| 610 | |
| 611 | /** |
| 612 | * A constant describing a motion detect sensor. |
| 613 | * |
| 614 | * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details. |
| 615 | * |
| 616 | */ |
| 617 | public static final int TYPE_HEART_BEAT = 31; |
| 618 | |
| 619 | /** |
| 620 | * A constant string describing a heart beat sensor. |
| 621 | * |
| 622 | * @see #TYPE_HEART_BEAT |
| 623 | */ |
| 624 | |
| 625 | public static final String STRING_TYPE_HEART_BEAT = "android.sensor.heart_beat"; |
Trevor Bunker | 3c288e6 | 2016-01-08 11:11:13 -0800 | [diff] [blame] | 626 | /** |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 627 | * A constant describing a dynamic sensor meta event sensor. |
| 628 | * |
| 629 | * A sensor event of this type is received when a dynamic sensor is added to or removed from |
| 630 | * the system. This sensor type should always use special trigger report mode ({@code |
| 631 | * SensorManager.REPORTING_MODE_SPECIAL_TRIGGER}). |
| 632 | * |
| 633 | * @hide This sensor is expected to be used only by system services. |
| 634 | */ |
| 635 | @SystemApi |
| 636 | public static final int TYPE_DYNAMIC_SENSOR_META = 32; |
| 637 | |
| 638 | /** |
| 639 | * A constant string describing a dynamic sensor meta event sensor. |
| 640 | * |
| 641 | * @see #TYPE_DYNAMIC_SENSOR_META |
| 642 | * |
| 643 | * @hide This sensor is expected to only be used by the system service |
| 644 | */ |
| 645 | @SystemApi |
| 646 | public static final String STRING_TYPE_DYNAMIC_SENSOR_META = |
| 647 | "android.sensor.dynamic_sensor_meta"; |
| 648 | |
| 649 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 650 | * A constant describing all sensor types. |
| 651 | */ |
Ashutosh Joshi | af1a266 | 2016-01-25 20:24:20 -0800 | [diff] [blame] | 652 | |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 653 | public static final int TYPE_ALL = -1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 654 | |
Peng Xu | 370985d | 2016-03-04 11:09:24 -0800 | [diff] [blame] | 655 | /** |
| 656 | * The lowest sensor type vendor defined sensors can use. |
| 657 | * |
| 658 | * All vendor sensor types are greater than or equal to this constant. |
| 659 | * |
| 660 | */ |
| 661 | public static final int TYPE_DEVICE_PRIVATE_BASE = 0x10000; |
| 662 | |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 663 | // If this flag is set, the sensor defined as a wake up sensor. This field and REPORTING_MODE_* |
| 664 | // constants are defined as flags in sensors.h. Modify at both places if needed. |
| 665 | private static final int SENSOR_FLAG_WAKE_UP_SENSOR = 1; |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 666 | |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 667 | /** |
| 668 | * Events are reported at a constant rate which is set by the rate parameter of |
| 669 | * {@link SensorManager#registerListener(SensorEventListener, Sensor, int)}. Note: If other |
| 670 | * applications are requesting a higher rate, the sensor data might be delivered at faster rates |
| 671 | * than requested. |
| 672 | */ |
| 673 | public static final int REPORTING_MODE_CONTINUOUS = 0; |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 674 | |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 675 | /** |
| 676 | * Events are reported only when the value changes. Event delivery rate can be limited by |
| 677 | * setting appropriate value for rate parameter of |
| 678 | * {@link SensorManager#registerListener(SensorEventListener, Sensor, int)} Note: If other |
| 679 | * applications are requesting a higher rate, the sensor data might be delivered at faster rates |
| 680 | * than requested. |
| 681 | */ |
| 682 | public static final int REPORTING_MODE_ON_CHANGE = 1; |
| 683 | |
| 684 | /** |
| 685 | * Events are reported in one-shot mode. Upon detection of an event, the sensor deactivates |
| 686 | * itself and then sends a single event. Sensors of this reporting mode must be registered to |
| 687 | * using {@link SensorManager#requestTriggerSensor(TriggerEventListener, Sensor)}. |
| 688 | */ |
| 689 | public static final int REPORTING_MODE_ONE_SHOT = 2; |
| 690 | |
| 691 | /** |
| 692 | * Events are reported as described in the description of the sensor. The rate passed to |
| 693 | * registerListener might not have an impact on the rate of event delivery. See the sensor |
| 694 | * definition for more information on when and how frequently the events are reported. For |
| 695 | * example, step detectors report events when a step is detected. |
| 696 | * |
| 697 | * @see SensorManager#registerListener(SensorEventListener, Sensor, int, int) |
| 698 | */ |
| 699 | public static final int REPORTING_MODE_SPECIAL_TRIGGER = 3; |
| 700 | |
| 701 | // Mask for the LSB 2nd, 3rd and fourth bits. |
| 702 | private static final int REPORTING_MODE_MASK = 0xE; |
| 703 | private static final int REPORTING_MODE_SHIFT = 1; |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 704 | |
Aravind Akella | 18ebf732b | 2015-04-20 17:39:51 -0700 | [diff] [blame] | 705 | // MASK for LSB fifth bit. Used to know whether the sensor supports data injection or not. |
| 706 | private static final int DATA_INJECTION_MASK = 0x10; |
| 707 | private static final int DATA_INJECTION_SHIFT = 4; |
| 708 | |
Jaikumar Ganesh | edb5242 | 2013-04-16 11:10:05 -0700 | [diff] [blame] | 709 | // TODO(): The following arrays are fragile and error-prone. This needs to be refactored. |
| 710 | |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 711 | // Note: This needs to be updated, whenever a new sensor is added. |
Mathias Agopian | b25c0ef | 2013-07-03 15:38:29 -0700 | [diff] [blame] | 712 | // Holds the reporting mode and maximum length of the values array |
| 713 | // associated with |
| 714 | // {@link SensorEvent} or {@link TriggerEvent} for the Sensor |
| 715 | private static final int[] sSensorReportingModes = { |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 716 | 0, // padding because sensor types start at 1 |
| 717 | 3, // SENSOR_TYPE_ACCELEROMETER |
| 718 | 3, // SENSOR_TYPE_GEOMAGNETIC_FIELD |
| 719 | 3, // SENSOR_TYPE_ORIENTATION |
| 720 | 3, // SENSOR_TYPE_GYROSCOPE |
| 721 | 3, // SENSOR_TYPE_LIGHT |
| 722 | 3, // SENSOR_TYPE_PRESSURE |
| 723 | 3, // SENSOR_TYPE_TEMPERATURE |
| 724 | 3, // SENSOR_TYPE_PROXIMITY |
| 725 | 3, // SENSOR_TYPE_GRAVITY |
| 726 | 3, // SENSOR_TYPE_LINEAR_ACCELERATION |
| 727 | 5, // SENSOR_TYPE_ROTATION_VECTOR |
| 728 | 3, // SENSOR_TYPE_RELATIVE_HUMIDITY |
| 729 | 3, // SENSOR_TYPE_AMBIENT_TEMPERATURE |
| 730 | 6, // SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED |
| 731 | 4, // SENSOR_TYPE_GAME_ROTATION_VECTOR |
| 732 | 6, // SENSOR_TYPE_GYROSCOPE_UNCALIBRATED |
| 733 | 1, // SENSOR_TYPE_SIGNIFICANT_MOTION |
| 734 | 1, // SENSOR_TYPE_STEP_DETECTOR |
| 735 | 1, // SENSOR_TYPE_STEP_COUNTER |
| 736 | 5, // SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR |
| 737 | 1, // SENSOR_TYPE_HEART_RATE_MONITOR |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 738 | 1, // SENSOR_TYPE_WAKE_UP_TILT_DETECTOR |
| 739 | 1, // SENSOR_TYPE_WAKE_GESTURE |
Jeff Brown | 241e70d | 2014-07-17 15:12:37 -0700 | [diff] [blame] | 740 | 1, // SENSOR_TYPE_GLANCE_GESTURE |
Aravind Akella | 96eb62c | 2014-07-17 12:42:00 -0700 | [diff] [blame] | 741 | 1, // SENSOR_TYPE_PICK_UP_GESTURE |
Nick Vaccaro | f5021f6 | 2015-01-23 15:09:45 -0800 | [diff] [blame] | 742 | 1, // SENSOR_TYPE_WRIST_TILT_GESTURE |
Trevor Bunker | 3c288e6 | 2016-01-08 11:11:13 -0800 | [diff] [blame] | 743 | 1, // SENSOR_TYPE_DEVICE_ORIENTATION |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 744 | 16,// SENSOR_TYPE_POSE_6DOF |
| 745 | 1, // SENSOR_TYPE_STATIONARY_DETECT |
| 746 | 1, // SENSOR_TYPE_MOTION_DETECT |
| 747 | 1, // SENSOR_TYPE_HEART_BEAT |
| 748 | 2, // SENSOR_TYPE_DYNAMIC_SENSOR_META |
Mathias Agopian | b25c0ef | 2013-07-03 15:38:29 -0700 | [diff] [blame] | 749 | }; |
Jaikumar Ganesh | 6d0c1d78 | 2013-03-27 17:41:33 -0700 | [diff] [blame] | 750 | |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 751 | /** |
| 752 | * Each sensor has exactly one reporting mode associated with it. This method returns the |
| 753 | * reporting mode constant for this sensor type. |
| 754 | * |
| 755 | * @return Reporting mode for the input sensor, one of REPORTING_MODE_* constants. |
| 756 | * @see #REPORTING_MODE_CONTINUOUS |
| 757 | * @see #REPORTING_MODE_ON_CHANGE |
| 758 | * @see #REPORTING_MODE_ONE_SHOT |
| 759 | * @see #REPORTING_MODE_SPECIAL_TRIGGER |
| 760 | */ |
| 761 | public int getReportingMode() { |
| 762 | return ((mFlags & REPORTING_MODE_MASK) >> REPORTING_MODE_SHIFT); |
Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 763 | } |
| 764 | |
Jaikumar Ganesh | 6d0c1d78 | 2013-03-27 17:41:33 -0700 | [diff] [blame] | 765 | static int getMaxLengthValuesArray(Sensor sensor, int sdkLevel) { |
Jaikumar Ganesh | 6d0c1d78 | 2013-03-27 17:41:33 -0700 | [diff] [blame] | 766 | // RotationVector length has changed to 3 to 5 for API level 18 |
| 767 | // Set it to 3 for backward compatibility. |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 768 | if (sensor.mType == Sensor.TYPE_ROTATION_VECTOR && |
Jaikumar Ganesh | 6d0c1d78 | 2013-03-27 17:41:33 -0700 | [diff] [blame] | 769 | sdkLevel <= Build.VERSION_CODES.JELLY_BEAN_MR1) { |
Mathias Agopian | b25c0ef | 2013-07-03 15:38:29 -0700 | [diff] [blame] | 770 | return 3; |
Jaikumar Ganesh | 6d0c1d78 | 2013-03-27 17:41:33 -0700 | [diff] [blame] | 771 | } |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 772 | int offset = sensor.mType; |
Mathias Agopian | b25c0ef | 2013-07-03 15:38:29 -0700 | [diff] [blame] | 773 | if (offset >= sSensorReportingModes.length) { |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 774 | // we don't know about this sensor, so this is probably a vendor-defined sensor, in that |
| 775 | // case, we don't know how many value it has so we return the maximum and assume the app |
| 776 | // will know. |
| 777 | // FIXME: sensor HAL should advertise how much data is returned per sensor |
Mathias Agopian | b25c0ef | 2013-07-03 15:38:29 -0700 | [diff] [blame] | 778 | return 16; |
| 779 | } |
| 780 | return sSensorReportingModes[offset]; |
Jaikumar Ganesh | 6d0c1d78 | 2013-03-27 17:41:33 -0700 | [diff] [blame] | 781 | } |
| 782 | |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 783 | /* Some of these fields are set only by the native bindings in |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 784 | * SensorManager. |
| 785 | */ |
| 786 | private String mName; |
| 787 | private String mVendor; |
| 788 | private int mVersion; |
| 789 | private int mHandle; |
| 790 | private int mType; |
| 791 | private float mMaxRange; |
| 792 | private float mResolution; |
| 793 | private float mPower; |
Mathias Agopian | 050b562 | 2010-07-29 16:51:38 -0700 | [diff] [blame] | 794 | private int mMinDelay; |
Aravind Akella | b4c76b1 | 2013-06-27 12:04:16 -0700 | [diff] [blame] | 795 | private int mFifoReservedEventCount; |
| 796 | private int mFifoMaxEventCount; |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 797 | private String mStringType; |
| 798 | private String mRequiredPermission; |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 799 | private int mMaxDelay; |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 800 | private int mFlags; |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 801 | private UUID mUuid; |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 802 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 803 | Sensor() { |
| 804 | } |
| 805 | |
| 806 | /** |
| 807 | * @return name string of the sensor. |
| 808 | */ |
| 809 | public String getName() { |
| 810 | return mName; |
| 811 | } |
| 812 | |
| 813 | /** |
| 814 | * @return vendor string of this sensor. |
| 815 | */ |
| 816 | public String getVendor() { |
| 817 | return mVendor; |
| 818 | } |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 819 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 820 | /** |
| 821 | * @return generic type of this sensor. |
| 822 | */ |
| 823 | public int getType() { |
| 824 | return mType; |
| 825 | } |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 826 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 827 | /** |
| 828 | * @return version of the sensor's module. |
| 829 | */ |
| 830 | public int getVersion() { |
| 831 | return mVersion; |
| 832 | } |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 833 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 834 | /** |
| 835 | * @return maximum range of the sensor in the sensor's unit. |
| 836 | */ |
| 837 | public float getMaximumRange() { |
| 838 | return mMaxRange; |
| 839 | } |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 840 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 841 | /** |
| 842 | * @return resolution of the sensor in the sensor's unit. |
| 843 | */ |
| 844 | public float getResolution() { |
| 845 | return mResolution; |
| 846 | } |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 847 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 848 | /** |
| 849 | * @return the power in mA used by this sensor while in use |
| 850 | */ |
| 851 | public float getPower() { |
| 852 | return mPower; |
| 853 | } |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 854 | |
Mathias Agopian | 050b562 | 2010-07-29 16:51:38 -0700 | [diff] [blame] | 855 | /** |
| 856 | * @return the minimum delay allowed between two events in microsecond |
| 857 | * or zero if this sensor only returns a value when the data it's measuring |
| 858 | * changes. |
| 859 | */ |
| 860 | public int getMinDelay() { |
| 861 | return mMinDelay; |
| 862 | } |
| 863 | |
Aravind Akella | b4c76b1 | 2013-06-27 12:04:16 -0700 | [diff] [blame] | 864 | /** |
| 865 | * @return Number of events reserved for this sensor in the batch mode FIFO. This gives a |
Aravind Akella | d405e0f | 2013-09-04 12:07:33 -0700 | [diff] [blame] | 866 | * guarantee on the minimum number of events that can be batched. |
Aravind Akella | b4c76b1 | 2013-06-27 12:04:16 -0700 | [diff] [blame] | 867 | */ |
| 868 | public int getFifoReservedEventCount() { |
| 869 | return mFifoReservedEventCount; |
| 870 | } |
| 871 | |
| 872 | /** |
| 873 | * @return Maximum number of events of this sensor that could be batched. If this value is zero |
| 874 | * it indicates that batch mode is not supported for this sensor. If other applications |
| 875 | * registered to batched sensors, the actual number of events that can be batched might be |
| 876 | * smaller because the hardware FiFo will be partially used to batch the other sensors. |
Aravind Akella | b4c76b1 | 2013-06-27 12:04:16 -0700 | [diff] [blame] | 877 | */ |
| 878 | public int getFifoMaxEventCount() { |
| 879 | return mFifoMaxEventCount; |
| 880 | } |
| 881 | |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 882 | /** |
| 883 | * @return The type of this sensor as a string. |
| 884 | */ |
| 885 | public String getStringType() { |
| 886 | return mStringType; |
| 887 | } |
| 888 | |
| 889 | /** |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 890 | * @return The type of this sensor as a string. |
| 891 | */ |
| 892 | public UUID getUuid() { |
| 893 | return mUuid; |
| 894 | } |
| 895 | |
| 896 | /** |
Aravind Akella | b613dba | 2014-05-21 14:14:45 -0700 | [diff] [blame] | 897 | * @hide |
Aravind Akella | cd9a7bb | 2014-04-07 22:55:21 +0000 | [diff] [blame] | 898 | * @return The permission required to access this sensor. If empty, no permission is required. |
| 899 | */ |
| 900 | public String getRequiredPermission() { |
| 901 | return mRequiredPermission; |
| 902 | } |
| 903 | |
Mathias Agopian | 7f84c06 | 2013-02-04 19:22:47 -0800 | [diff] [blame] | 904 | /** @hide */ |
| 905 | public int getHandle() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 906 | return mHandle; |
| 907 | } |
Mathias Agopian | 74cde2c | 2010-06-16 18:55:46 -0700 | [diff] [blame] | 908 | |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 909 | /** |
Aravind Akella | e57676b | 2014-09-04 16:24:41 -0700 | [diff] [blame] | 910 | * This value is defined only for continuous and on-change sensors. It is the delay between two |
| 911 | * sensor events corresponding to the lowest frequency that this sensor supports. When lower |
| 912 | * frequencies are requested through registerListener() the events will be generated at this |
| 913 | * frequency instead. It can be used to estimate when the batch FIFO may be full. Older devices |
| 914 | * may set this value to zero. Ignore this value in case it is negative or zero. |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 915 | * |
| 916 | * @return The max delay for this sensor in microseconds. |
| 917 | */ |
| 918 | public int getMaxDelay() { |
| 919 | return mMaxDelay; |
| 920 | } |
| 921 | |
| 922 | /** |
Aravind Akella | 1f9b32f | 2014-09-16 15:21:44 -0700 | [diff] [blame] | 923 | * Returns true if the sensor is a wake-up sensor. |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 924 | * <p> |
Aravind Akella | 1f9b32f | 2014-09-16 15:21:44 -0700 | [diff] [blame] | 925 | * <b>Application Processor Power modes</b> <p> |
| 926 | * Application Processor(AP), is the processor on which applications run. When no wake lock is held |
| 927 | * and the user is not interacting with the device, this processor can enter a “Suspend” mode, |
| 928 | * reducing the power consumption by 10 times or more. |
| 929 | * </p> |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 930 | * <p> |
Aravind Akella | 1f9b32f | 2014-09-16 15:21:44 -0700 | [diff] [blame] | 931 | * <b>Non-wake-up sensors</b> <p> |
| 932 | * Non-wake-up sensors are sensors that do not wake the AP out of suspend to report data. While |
| 933 | * the AP is in suspend mode, the sensors continue to function and generate events, which are |
| 934 | * put in a hardware FIFO. The events in the FIFO are delivered to the application when the AP |
| 935 | * wakes up. If the FIFO was too small to store all events generated while the AP was in |
| 936 | * suspend mode, the older events are lost: the oldest data is dropped to accommodate the newer |
| 937 | * data. In the extreme case where the FIFO is non-existent {@code maxFifoEventCount() == 0}, |
| 938 | * all events generated while the AP was in suspend mode are lost. Applications using |
| 939 | * non-wake-up sensors should usually: |
| 940 | * <ul> |
| 941 | * <li>Either unregister from the sensors when they do not need them, usually in the activity’s |
| 942 | * {@code onPause} method. This is the most common case. |
| 943 | * <li>Or realize that the sensors are consuming some power while the AP is in suspend mode and |
| 944 | * that even then, some events might be lost. |
| 945 | * </ul> |
| 946 | * </p> |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 947 | * <p> |
Aravind Akella | 1f9b32f | 2014-09-16 15:21:44 -0700 | [diff] [blame] | 948 | * <b>Wake-up sensors</b> <p> |
| 949 | * In opposition to non-wake-up sensors, wake-up sensors ensure that their data is delivered |
| 950 | * independently of the state of the AP. While the AP is awake, the wake-up sensors behave |
| 951 | * like non-wake-up-sensors. When the AP is asleep, wake-up sensors wake up the AP to deliver |
| 952 | * events. That is, the AP will wake up and the sensor will deliver the events before the |
| 953 | * maximum reporting latency is elapsed or the hardware FIFO gets full. See {@link |
| 954 | * SensorManager#registerListener(SensorEventListener, Sensor, int, int)} for more details. |
| 955 | * </p> |
| 956 | * |
| 957 | * @return <code>true</code> if this is a wake-up sensor, <code>false</code> otherwise. |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 958 | */ |
| 959 | public boolean isWakeUpSensor() { |
Aravind Akella | 2790035 | 2014-06-03 19:20:42 -0700 | [diff] [blame] | 960 | return (mFlags & SENSOR_FLAG_WAKE_UP_SENSOR) != 0; |
Aravind Akella | 2f8b914 | 2014-05-12 14:39:29 -0700 | [diff] [blame] | 961 | } |
| 962 | |
Aravind Akella | 18ebf732b | 2015-04-20 17:39:51 -0700 | [diff] [blame] | 963 | /** |
| 964 | * Returns true if the sensor supports data injection when the |
| 965 | * HAL is set to data injection mode. |
| 966 | * |
| 967 | * @return <code>true</code> if the sensor supports data |
| 968 | * injection when the HAL is set in injection mode, |
| 969 | * false otherwise. |
| 970 | * @hide |
| 971 | */ |
| 972 | @SystemApi |
| 973 | public boolean isDataInjectionSupported() { |
| 974 | return (((mFlags & DATA_INJECTION_MASK) >> DATA_INJECTION_SHIFT)) != 0; |
| 975 | } |
| 976 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 977 | void setRange(float max, float res) { |
| 978 | mMaxRange = max; |
| 979 | mResolution = res; |
| 980 | } |
Jeff Brown | 6a2ef12 | 2012-08-10 18:19:10 -0700 | [diff] [blame] | 981 | |
| 982 | @Override |
| 983 | public String toString() { |
| 984 | return "{Sensor name=\"" + mName + "\", vendor=\"" + mVendor + "\", version=" + mVersion |
| 985 | + ", type=" + mType + ", maxRange=" + mMaxRange + ", resolution=" + mResolution |
| 986 | + ", power=" + mPower + ", minDelay=" + mMinDelay + "}"; |
| 987 | } |
destradaa | 9ba7c1c | 2015-02-10 15:04:43 -0800 | [diff] [blame] | 988 | |
| 989 | /** |
| 990 | * Sets the Type associated with the sensor. |
| 991 | * NOTE: to be used only by native bindings in SensorManager. |
| 992 | * |
| 993 | * This allows interned static strings to be used across all representations of the Sensor. If |
| 994 | * a sensor type is not referenced here, it will still be interned by the native SensorManager. |
| 995 | * |
| 996 | * @return {@code true} if the StringType was successfully set, {@code false} otherwise. |
| 997 | */ |
| 998 | private boolean setType(int value) { |
| 999 | mType = value; |
| 1000 | switch (mType) { |
| 1001 | case TYPE_ACCELEROMETER: |
| 1002 | mStringType = STRING_TYPE_ACCELEROMETER; |
| 1003 | return true; |
| 1004 | case TYPE_AMBIENT_TEMPERATURE: |
| 1005 | mStringType = STRING_TYPE_AMBIENT_TEMPERATURE; |
| 1006 | return true; |
| 1007 | case TYPE_GAME_ROTATION_VECTOR: |
| 1008 | mStringType = STRING_TYPE_GAME_ROTATION_VECTOR; |
| 1009 | return true; |
| 1010 | case TYPE_GEOMAGNETIC_ROTATION_VECTOR: |
| 1011 | mStringType = STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR; |
| 1012 | return true; |
| 1013 | case TYPE_GLANCE_GESTURE: |
| 1014 | mStringType = STRING_TYPE_GLANCE_GESTURE; |
| 1015 | return true; |
| 1016 | case TYPE_GRAVITY: |
| 1017 | mStringType = STRING_TYPE_GRAVITY; |
| 1018 | return true; |
| 1019 | case TYPE_GYROSCOPE: |
| 1020 | mStringType = STRING_TYPE_GYROSCOPE; |
| 1021 | return true; |
| 1022 | case TYPE_GYROSCOPE_UNCALIBRATED: |
| 1023 | mStringType = STRING_TYPE_GYROSCOPE_UNCALIBRATED; |
| 1024 | return true; |
| 1025 | case TYPE_HEART_RATE: |
| 1026 | mStringType = STRING_TYPE_HEART_RATE; |
| 1027 | return true; |
| 1028 | case TYPE_LIGHT: |
| 1029 | mStringType = STRING_TYPE_LIGHT; |
| 1030 | return true; |
| 1031 | case TYPE_LINEAR_ACCELERATION: |
| 1032 | mStringType = STRING_TYPE_LINEAR_ACCELERATION; |
| 1033 | return true; |
| 1034 | case TYPE_MAGNETIC_FIELD: |
| 1035 | mStringType = STRING_TYPE_MAGNETIC_FIELD; |
| 1036 | return true; |
| 1037 | case TYPE_MAGNETIC_FIELD_UNCALIBRATED: |
| 1038 | mStringType = STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED; |
| 1039 | return true; |
| 1040 | case TYPE_PICK_UP_GESTURE: |
| 1041 | mStringType = STRING_TYPE_PICK_UP_GESTURE; |
| 1042 | return true; |
| 1043 | case TYPE_PRESSURE: |
| 1044 | mStringType = STRING_TYPE_PRESSURE; |
| 1045 | return true; |
| 1046 | case TYPE_PROXIMITY: |
| 1047 | mStringType = STRING_TYPE_PROXIMITY; |
| 1048 | return true; |
| 1049 | case TYPE_RELATIVE_HUMIDITY: |
| 1050 | mStringType = STRING_TYPE_RELATIVE_HUMIDITY; |
| 1051 | return true; |
| 1052 | case TYPE_ROTATION_VECTOR: |
| 1053 | mStringType = STRING_TYPE_ROTATION_VECTOR; |
| 1054 | return true; |
| 1055 | case TYPE_SIGNIFICANT_MOTION: |
| 1056 | mStringType = STRING_TYPE_SIGNIFICANT_MOTION; |
| 1057 | return true; |
| 1058 | case TYPE_STEP_COUNTER: |
| 1059 | mStringType = STRING_TYPE_STEP_COUNTER; |
| 1060 | return true; |
| 1061 | case TYPE_STEP_DETECTOR: |
| 1062 | mStringType = STRING_TYPE_STEP_DETECTOR; |
| 1063 | return true; |
| 1064 | case TYPE_TILT_DETECTOR: |
| 1065 | mStringType = SENSOR_STRING_TYPE_TILT_DETECTOR; |
| 1066 | return true; |
| 1067 | case TYPE_WAKE_GESTURE: |
| 1068 | mStringType = STRING_TYPE_WAKE_GESTURE; |
| 1069 | return true; |
| 1070 | case TYPE_ORIENTATION: |
| 1071 | mStringType = STRING_TYPE_ORIENTATION; |
| 1072 | return true; |
| 1073 | case TYPE_TEMPERATURE: |
| 1074 | mStringType = STRING_TYPE_TEMPERATURE; |
| 1075 | return true; |
Trevor Bunker | 3c288e6 | 2016-01-08 11:11:13 -0800 | [diff] [blame] | 1076 | case TYPE_DEVICE_ORIENTATION: |
| 1077 | mStringType = STRING_TYPE_DEVICE_ORIENTATION; |
| 1078 | return true; |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 1079 | case TYPE_DYNAMIC_SENSOR_META: |
| 1080 | mStringType = STRING_TYPE_DYNAMIC_SENSOR_META; |
| 1081 | return true; |
destradaa | 9ba7c1c | 2015-02-10 15:04:43 -0800 | [diff] [blame] | 1082 | default: |
| 1083 | return false; |
| 1084 | } |
| 1085 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1086 | } |