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