1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit SensorServiceKit 19 */ 20 21/** 22 * @interface AccelerometerResponse 23 * @permission ohos.permission.ACCELEROMETER 24 * @syscap SystemCapability.Sensors.Sensor.Lite 25 * @since 3 26 * @deprecated since 8 27 * @useinstead ohos.sensor/sensor#AccelerometerResponse 28 */ 29export interface AccelerometerResponse { 30 /** 31 * X-coordinate 32 * 33 * @permission ohos.permission.ACCELEROMETER 34 * @type { number } 35 * @syscap SystemCapability.Sensors.Sensor.Lite 36 * @since 3 37 * @deprecated since 8 38 */ 39 x: number; 40 41 /** 42 * Y-coordinate 43 * 44 * @permission ohos.permission.ACCELEROMETER 45 * @type { number } 46 * @syscap SystemCapability.Sensors.Sensor.Lite 47 * @since 3 48 * @deprecated since 8 49 */ 50 y: number; 51 52 /** 53 * Z-coordinate 54 * 55 * @permission ohos.permission.ACCELEROMETER 56 * @type { number } 57 * @syscap SystemCapability.Sensors.Sensor.Lite 58 * @since 3 59 * @deprecated since 8 60 */ 61 z: number; 62} 63 64/** 65 * @interface subscribeAccelerometerOptions 66 * @permission ohos.permission.ACCELEROMETER 67 * @syscap SystemCapability.Sensors.Sensor.Lite 68 * @since 3 69 * @deprecated since 8 70 * @useinstead ohos.sensor/sensor.SensorId#ACCELEROMETER 71 */ 72export interface subscribeAccelerometerOptions { 73 /** 74 * Execution frequency of the callback function for listening to acceleration sensor data. 75 * Available values are as follows: 76 * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. 77 * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. 78 * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. 79 * The default value is normal. 80 * 81 * @permission ohos.permission.ACCELEROMETER 82 * @type { string } 83 * @syscap SystemCapability.Sensors.Sensor.Lite 84 * @since 3 85 * @deprecated since 8 86 */ 87 interval: string; 88 89 /** 90 * Called when acceleration sensor data changes. 91 * 92 * @permission ohos.permission.ACCELEROMETER 93 * @type { function } 94 * @syscap SystemCapability.Sensors.Sensor.Lite 95 * @since 3 96 * @deprecated since 8 97 */ 98 success: (data: AccelerometerResponse) => void; 99 100 /** 101 * Called when the listening fails. 102 * 103 * @permission ohos.permission.ACCELEROMETER 104 * @type { ?function } 105 * @syscap SystemCapability.Sensors.Sensor.Lite 106 * @since 3 107 * @deprecated since 8 108 */ 109 fail?: (data: string, code: number) => void; 110} 111 112/** 113 * @interface CompassResponse 114 * @syscap SystemCapability.Sensors.Sensor.Lite 115 * @since 3 116 * @deprecated since 8 117 * @useinstead ohos.sensor/sensor#MagneticFieldResponse 118 */ 119export interface CompassResponse { 120 /** 121 * Direction of the device (in degrees). 122 * 123 * @type { number } 124 * @syscap SystemCapability.Sensors.Sensor.Lite 125 * @since 3 126 * @deprecated since 8 127 */ 128 direction: number; 129} 130 131/** 132 * @interface SubscribeCompassOptions 133 * @syscap SystemCapability.Sensors.Sensor.Lite 134 * @since 3 135 * @deprecated since 8 136 * @useinstead ohos.sensor/sensor.SensorId#MAGNETIC_FIELD 137 */ 138export interface SubscribeCompassOptions { 139 /** 140 * Called when compass sensor data changes. 141 * 142 * @type { function } 143 * @syscap SystemCapability.Sensors.Sensor.Lite 144 * @since 3 145 * @deprecated since 8 146 */ 147 success: (data: CompassResponse) => void; 148 149 /** 150 * Called when the listening fails. 151 * 152 * @type { ?function } 153 * @syscap SystemCapability.Sensors.Sensor.Lite 154 * @since 3 155 * @deprecated since 8 156 */ 157 fail?: (data: string, code: number) => void; 158} 159 160/** 161 * @interface ProximityResponse 162 * @syscap SystemCapability.Sensors.Sensor.Lite 163 * @since 3 164 * @deprecated since 8 165 * @useinstead ohos.sensor/sensor#ProximityResponse 166 */ 167export interface ProximityResponse { 168 /** 169 * Distance between a visible object and the device screen 170 * 171 * @type { number } 172 * @syscap SystemCapability.Sensors.Sensor.Lite 173 * @since 3 174 * @deprecated since 8 175 */ 176 distance: number; 177} 178 179/** 180 * @interface SubscribeProximityOptions 181 * @syscap SystemCapability.Sensors.Sensor.Lite 182 * @since 3 183 * @deprecated since 8 184 * @useinstead ohos.sensor/sensor.SensorId#PROXIMITY 185 */ 186export interface SubscribeProximityOptions { 187 /** 188 * Called when distance sensor data changes. 189 * 190 * @type { function } 191 * @syscap SystemCapability.Sensors.Sensor.Lite 192 * @since 3 193 * @deprecated since 8 194 */ 195 success: (data: ProximityResponse) => void; 196 197 /** 198 * Called when the listening fails. 199 * 200 * @type { ?function } 201 * @syscap SystemCapability.Sensors.Sensor.Lite 202 * @since 3 203 * @deprecated since 8 204 */ 205 fail?: (data: string, code: number) => void; 206} 207 208/** 209 * @interface LightResponse 210 * @syscap SystemCapability.Sensors.Sensor.Lite 211 * @since 3 212 * @deprecated since 8 213 * @useinstead ohos.sensor/sensor#LightResponse 214 */ 215export interface LightResponse { 216 /** 217 * Light intensity, in lux. 218 * 219 * @type { number } 220 * @syscap SystemCapability.Sensors.Sensor.Lite 221 * @since 3 222 * @deprecated since 8 223 */ 224 intensity: number; 225} 226 227/** 228 * @interface SubscribeLightOptions 229 * @syscap SystemCapability.Sensors.Sensor.Lite 230 * @since 3 231 * @deprecated since 8 232 * @useinstead ohos.sensor/sensor.SensorId#AMBIENT_LIGHT 233 */ 234export interface SubscribeLightOptions { 235 /** 236 * Called when ambient light sensor data changes. 237 * 238 * @type { function } 239 * @syscap SystemCapability.Sensors.Sensor.Lite 240 * @since 3 241 * @deprecated since 8 242 */ 243 success: (data: LightResponse) => void; 244 245 /** 246 * Called when the listening fails. 247 * 248 * @type { ?function } 249 * @syscap SystemCapability.Sensors.Sensor.Lite 250 * @since 3 251 * @deprecated since 8 252 */ 253 fail?: (data: string, code: number) => void; 254} 255 256/** 257 * @interface StepCounterResponse 258 * @permission ohos.permission.ACTIVITY_MOTION 259 * @syscap SystemCapability.Sensors.Sensor.Lite 260 * @since 3 261 * @deprecated since 8 262 * @useinstead ohos.sensor/sensor#PedometerResponse 263 */ 264export interface StepCounterResponse { 265 /** 266 * Number of steps counted. 267 * Each time the device restarts, the value is recalculated from 0 in phone, tablet. 268 * 269 * @permission ohos.permission.ACTIVITY_MOTION 270 * @type { number } 271 * @syscap SystemCapability.Sensors.Sensor.Lite 272 * @since 3 273 * @deprecated since 8 274 */ 275 steps: number; 276} 277 278/** 279 * @interface SubscribeStepCounterOptions 280 * @permission ohos.permission.ACTIVITY_MOTION 281 * @syscap SystemCapability.Sensors.Sensor.Lite 282 * @since 3 283 * @deprecated since 8 284 * @useinstead ohos.sensor/SensorId#PEDOMETER 285 */ 286export interface SubscribeStepCounterOptions { 287 /** 288 * Called when step counter sensor data changes. 289 * 290 * @permission ohos.permission.ACTIVITY_MOTION 291 * @type { function } 292 * @syscap SystemCapability.Sensors.Sensor.Lite 293 * @since 3 294 * @deprecated since 8 295 */ 296 success: (data: StepCounterResponse) => void; 297 298 /** 299 * Called when the listening fails. 300 * 301 * @permission ohos.permission.ACTIVITY_MOTION 302 * @type { ?function } 303 * @syscap SystemCapability.Sensors.Sensor.Lite 304 * @since 3 305 * @deprecated since 8 306 */ 307 fail?: (data: string, code: number) => void; 308} 309 310/** 311 * @interface BarometerResponse 312 * @syscap SystemCapability.Sensors.Sensor.Lite 313 * @since 3 314 * @deprecated since 8 315 * @useinstead ohos.sensor/sensor#BarometerResponse 316 */ 317export interface BarometerResponse { 318 /** 319 * Pressure, in hpa. 320 * 321 * @type { number } 322 * @syscap SystemCapability.Sensors.Sensor.Lite 323 * @since 3 324 * @deprecated since 8 325 */ 326 pressure: number; 327} 328 329/** 330 * @interface SubscribeBarometerOptions 331 * @syscap SystemCapability.Sensors.Sensor.Lite 332 * @since 3 333 * @deprecated since 8 334 * @useinstead ohos.sensor/sensor.SensorId#BAROMETER 335 */ 336export interface SubscribeBarometerOptions { 337 /** 338 * Called when the barometer sensor data changes. 339 * 340 * @type { function } 341 * @syscap SystemCapability.Sensors.Sensor.Lite 342 * @since 3 343 * @deprecated since 8 344 */ 345 success: (data: BarometerResponse) => void; 346 347 /** 348 * Called when the listening fails. 349 * 350 * @type { ?function } 351 * @syscap SystemCapability.Sensors.Sensor.Lite 352 * @since 3 353 * @deprecated since 8 354 */ 355 fail?: (data: string, code: number) => void; 356} 357 358/** 359 * @interface HeartRateResponse 360 * @permission ohos.permission.READ_HEALTH_DATA 361 * @syscap SystemCapability.Sensors.Sensor.Lite 362 * @since 3 363 * @deprecated since 8 364 * @useinstead ohos.sensor/sensor#HeartRateResponse 365 */ 366export interface HeartRateResponse { 367 /** 368 * Heart rate. 369 * 255 indicates an invalid value in lite wearable. 370 * 371 * @permission ohos.permission.READ_HEALTH_DATA 372 * @type { number } 373 * @syscap SystemCapability.Sensors.Sensor.Lite 374 * @since 3 375 * @deprecated since 8 376 */ 377 heartRate: number; 378} 379 380/** 381 * @interface SubscribeHeartRateOptions 382 * @permission ohos.permission.READ_HEALTH_DATA 383 * @syscap SystemCapability.Sensors.Sensor.Lite 384 * @since 3 385 * @deprecated since 8 386 * @useinstead ohos.sensor/sensor.SensorId#HEART_RATE 387 */ 388export interface SubscribeHeartRateOptions { 389 /** 390 * Called when the heart rate sensor data changes. 391 * 392 * @permission ohos.permission.READ_HEALTH_DATA 393 * @type { function } 394 * @syscap SystemCapability.Sensors.Sensor.Lite 395 * @since 3 396 * @deprecated since 8 397 */ 398 success: (data: HeartRateResponse) => void; 399 400 /** 401 * Called when the listening fails 402 * 403 * @permission ohos.permission.READ_HEALTH_DATA 404 * @type { ?function } 405 * @syscap SystemCapability.Sensors.Sensor.Lite 406 * @since 3 407 * @deprecated since 8 408 */ 409 fail?: (data: string, code: number) => void; 410} 411 412/** 413 * @interface OnBodyStateResponse 414 * @syscap SystemCapability.Sensors.Sensor.Lite 415 * @since 3 416 * @deprecated since 8 417 * @useinstead ohos.sensor/sensor#WearDetectionResponse 418 */ 419export interface OnBodyStateResponse { 420 /** 421 * Whether the sensor is worn. 422 * 423 * @type { boolean } 424 * @syscap SystemCapability.Sensors.Sensor.Lite 425 * @since 3 426 * @deprecated since 8 427 */ 428 value: boolean; 429} 430 431/** 432 * @interface SubscribeOnBodyStateOptions 433 * @syscap SystemCapability.Sensors.Sensor.Lite 434 * @since 3 435 * @deprecated since 8 436 * @useinstead ohos.sensor/sensor.SensorId#WEAR_DETECTION 437 */ 438export interface SubscribeOnBodyStateOptions { 439 /** 440 * Called when the wearing status changes. 441 * 442 * @type { function } 443 * @syscap SystemCapability.Sensors.Sensor.Lite 444 * @since 3 445 * @deprecated since 8 446 */ 447 success: (data: OnBodyStateResponse) => void; 448 449 /** 450 * Called when the listening fails. 451 * 452 * @type { ?function } 453 * @syscap SystemCapability.Sensors.Sensor.Lite 454 * @since 3 455 * @deprecated since 8 456 */ 457 fail?: (data: string, code: number) => void; 458} 459 460/** 461 * @interface GetOnBodyStateOptions 462 * @syscap SystemCapability.Sensors.Sensor.Lite 463 * @since 3 464 * @deprecated since 8 465 * @useinstead ohos.sensor/sensor.SensorId#WEAR_DETECTION 466 */ 467export interface GetOnBodyStateOptions { 468 /** 469 * Called when the sensor wearing state is obtained 470 * 471 * @type { function } 472 * @syscap SystemCapability.Sensors.Sensor.Lite 473 * @since 3 474 * @deprecated since 8 475 */ 476 success: (data: OnBodyStateResponse) => void; 477 478 /** 479 * Called when the sensor wearing state fails to be obtained 480 * 481 * @type { ?function } 482 * @syscap SystemCapability.Sensors.Sensor.Lite 483 * @since 3 484 * @deprecated since 8 485 */ 486 fail?: (data: string, code: number) => void; 487 488 /** 489 * Called when the execution is completed 490 * 491 * @type { ?function } 492 * @syscap SystemCapability.Sensors.Sensor.Lite 493 * @since 3 494 * @deprecated since 8 495 */ 496 complete?: () => void; 497} 498 499/** 500 * @interface DeviceOrientationResponse 501 * @syscap SystemCapability.Sensors.Sensor.Lite 502 * @since 6 503 * @deprecated since 8 504 * @useinstead ohos.sensor/sensor#OrientationResponse 505 */ 506export interface DeviceOrientationResponse { 507 /** 508 * alpha 509 * 510 * @type { number } 511 * @syscap SystemCapability.Sensors.Sensor.Lite 512 * @since 6 513 * @deprecated since 8 514 */ 515 alpha: number; 516 517 /** 518 * beta 519 * 520 * @type { number } 521 * @syscap SystemCapability.Sensors.Sensor.Lite 522 * @since 6 523 * @deprecated since 8 524 */ 525 beta: number; 526 527 /** 528 * gamma 529 * 530 * @type { number } 531 * @syscap SystemCapability.Sensors.Sensor.Lite 532 * @since 6 533 * @deprecated since 8 534 */ 535 gamma: number; 536} 537 538/** 539 * @interface SubscribeDeviceOrientationOptions 540 * @syscap SystemCapability.Sensors.Sensor.Lite 541 * @since 6 542 * @deprecated since 8 543 * @useinstead ohos.sensor/sensor.SensorId#ORIENTATION 544 */ 545export interface SubscribeDeviceOrientationOptions { 546 /** 547 * Execution frequency of the callback function for listening to device orientation sensor data. 548 * Available values are as follows: 549 * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. 550 * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. 551 * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. 552 * The default value is normal. 553 * 554 * @type { string } 555 * @syscap SystemCapability.Sensors.Sensor.Lite 556 * @since 6 557 * @deprecated since 8 558 */ 559 interval: string; 560 561 /** 562 * Called when device orientation sensor data changes. 563 * 564 * @type { function} 565 * @syscap SystemCapability.Sensors.Sensor.Lite 566 * @since 6 567 * @deprecated since 8 568 */ 569 success: (data: DeviceOrientationResponse) => void; 570 571 /** 572 * Called when the listening fails. 573 * 574 * @type { ?function } 575 * @syscap SystemCapability.Sensors.Sensor.Lite 576 * @since 6 577 * @deprecated since 8 578 */ 579 fail?: (data: string, code: number) => void; 580} 581 582/** 583 * @interface GyroscopeResponse 584 * @permission ohos.permission.GYROSCOPE 585 * @syscap SystemCapability.Sensors.Sensor.Lite 586 * @since 6 587 * @deprecated since 8 588 * @useinstead ohos.sensor/sensor#GyroscopeResponse 589 */ 590export interface GyroscopeResponse { 591 /** 592 * X-coordinate 593 * 594 * @permission ohos.permission.GYROSCOPE 595 * @type { number } 596 * @syscap SystemCapability.Sensors.Sensor.Lite 597 * @since 6 598 * @deprecated since 8 599 */ 600 x: number; 601 602 /** 603 * Y-coordinate 604 * 605 * @permission ohos.permission.GYROSCOPE 606 * @type { number } 607 * @syscap SystemCapability.Sensors.Sensor.Lite 608 * @since 6 609 * @deprecated since 8 610 */ 611 y: number; 612 613 /** 614 * Z-coordinate 615 * 616 * @permission ohos.permission.GYROSCOPE 617 * @type { number } 618 * @syscap SystemCapability.Sensors.Sensor.Lite 619 * @since 6 620 * @deprecated since 8 621 */ 622 z: number; 623} 624 625/** 626 * @interface SubscribeGyroscopeOptions 627 * @permission ohos.permission.GYROSCOPE 628 * @syscap SystemCapability.Sensors.Sensor.Lite 629 * @since 6 630 * @deprecated since 8 631 * @useinstead ohos.sensor/sensor.SensorId#GYROSCOPE 632 */ 633export interface SubscribeGyroscopeOptions { 634 /** 635 * Execution frequency of the callback function for listening to gyroscope sensor data. 636 * Available values are as follows: 637 * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. 638 * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. 639 * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. 640 * The default value is normal. 641 * 642 * @permission ohos.permission.GYROSCOPE 643 * @type { string } 644 * @syscap SystemCapability.Sensors.Sensor.Lite 645 * @since 6 646 * @deprecated since 8 647 */ 648 interval: string; 649 650 /** 651 * Called when gyroscope sensor data changes. 652 * 653 * @permission ohos.permission.GYROSCOPE 654 * @type { function } 655 * @syscap SystemCapability.Sensors.Sensor.Lite 656 * @since 6 657 * @deprecated since 8 658 */ 659 success: (data: GyroscopeResponse) => void; 660 661 /** 662 * Called when the listening fails. 663 * 664 * @permission ohos.permission.GYROSCOPE 665 * @type { ?function } 666 * @syscap SystemCapability.Sensors.Sensor.Lite 667 * @since 6 668 * @deprecated since 8 669 */ 670 fail?: (data: string, code: number) => void; 671} 672 673/** 674 * @syscap SystemCapability.Sensors.Sensor.Lite 675 * @since 6 676 * @deprecated since 8 677 * @useinstead ohos.sensor/sensor 678 */ 679export default class Sensor { 680 /** 681 * Listens to acceleration sensor data changes. 682 * If this API is called multiple times, the last call takes effect. 683 * 684 * @permission ohos.permission.ACCELEROMETER 685 * @param { subscribeAccelerometerOptions } options - options Options. 686 * @syscap SystemCapability.Sensors.Sensor.Lite 687 * @since 3 688 * @deprecated since 8 689 * @useinstead ohos.sensor/sensor.SensorId#ACCELEROMETER 690 */ 691 static subscribeAccelerometer(options: subscribeAccelerometerOptions): void; 692 693 /** 694 * Cancels listening to acceleration sensor data. 695 * 696 * @permission ohos.permission.ACCELEROMETER 697 * @syscap SystemCapability.Sensors.Sensor.Lite 698 * @since 3 699 * @deprecated since 8 700 * @useinstead ohos.sensor/sensor.SensorId#ACCELEROMETER 701 */ 702 static unsubscribeAccelerometer(): void; 703 704 /** 705 * Listens to compass sensor data changes. 706 * If this API is called multiple times, the last call takes effect. 707 * 708 * @param { SubscribeCompassOptions } options - Options. 709 * @syscap SystemCapability.Sensors.Sensor.Lite 710 * @since 3 711 * @deprecated since 8 712 * @useinstead ohos.sensor/sensor.SensorId#MAGNETIC_FIELD 713 */ 714 static subscribeCompass(options: SubscribeCompassOptions): void; 715 716 /** 717 * Cancels listening to compass sensor data. 718 * 719 * @syscap SystemCapability.Sensors.Sensor.Lite 720 * @since 3 721 * @deprecated since 8 722 * @useinstead ohos.sensor/sensor.SensorId#MAGNETIC_FIELD 723 */ 724 static unsubscribeCompass(): void; 725 726 /** 727 * Listens to distance sensor data changes. 728 * If this API is called multiple times, the last call takes effect. 729 * 730 * @param { SubscribeProximityOptions } options - options Options. 731 * @syscap SystemCapability.Sensors.Sensor.Lite 732 * @since 3 733 * @deprecated since 8 734 * @useinstead ohos.sensor/sensor.SensorId#PROXIMITY 735 */ 736 static subscribeProximity(options: SubscribeProximityOptions): void; 737 738 /** 739 * Cancels listening to distance sensor data. 740 * 741 * @syscap SystemCapability.Sensors.Sensor.Lite 742 * @since 3 743 * @deprecated since 8 744 * @useinstead ohos.sensor/sensor.SensorId#PROXIMITY 745 */ 746 static unsubscribeProximity(): void; 747 748 /** 749 * Listens to ambient light sensor data changes. 750 * If this API is called multiple times, the last call takes effect. 751 * 752 * @param { SubscribeLightOptions } options - options Options. 753 * @syscap SystemCapability.Sensors.Sensor.Lite 754 * @since 3 755 * @deprecated since 8 756 * @useinstead ohos.sensor/sensor.SensorId#AMBIENT_LIGHT 757 */ 758 static subscribeLight(options: SubscribeLightOptions): void; 759 760 /** 761 * Cancels listening to ambient light sensor data. 762 * 763 * @syscap SystemCapability.Sensors.Sensor.Lite 764 * @since 3 765 * @deprecated since 8 766 * @useinstead ohos.sensor/sensor.SensorId#AMBIENT_LIGHT 767 */ 768 static unsubscribeLight(): void; 769 770 /** 771 * Listens to step counter sensor data changes. 772 * If this API is called multiple times, the last call takes effect. 773 * 774 * @permission ohos.permission.ACTIVITY_MOTION 775 * @param { SubscribeStepCounterOptions } options - options Options. 776 * @syscap SystemCapability.Sensors.Sensor.Lite 777 * @since 3 778 * @deprecated since 8 779 * @useinstead ohos.sensor/sensor.SensorId#PEDOMETER 780 */ 781 static subscribeStepCounter(options: SubscribeStepCounterOptions): void; 782 783 /** 784 * Cancels listening to step counter sensor data. 785 * 786 * @permission ohos.permission.ACTIVITY_MOTION 787 * @syscap SystemCapability.Sensors.Sensor.Lite 788 * @since 3 789 * @deprecated since 8 790 * @useinstead ohos.sensor/sensor.SensorId#PEDOMETER 791 */ 792 static unsubscribeStepCounter(): void; 793 794 /** 795 * Listens to barometer sensor data changes. 796 * If this API is called multiple times, the last call takes effect. 797 * 798 * @param { SubscribeBarometerOptions } options - options Options. 799 * @syscap SystemCapability.Sensors.Sensor.Lite 800 * @since 3 801 * @deprecated since 8 802 * @useinstead ohos.sensor/sensor.SensorId#BAROMETER 803 */ 804 static subscribeBarometer(options: SubscribeBarometerOptions): void; 805 806 /** 807 * Cancels listening to barometer sensor data. 808 * 809 * @syscap SystemCapability.Sensors.Sensor.Lite 810 * @since 3 811 * @deprecated since 8 812 * @useinstead ohos.sensor/sensor.SensorId#BAROMETER 813 */ 814 static unsubscribeBarometer(): void; 815 816 /** 817 * Listens to changes of heart rate sensor data. 818 * If this API is called multiple times, the last call takes effect. 819 * 820 * @permission ohos.permission.READ_HEALTH_DATA 821 * @param { SubscribeHeartRateOptions } options - options Options. 822 * @syscap SystemCapability.Sensors.Sensor.Lite 823 * @since 3 824 * @deprecated since 8 825 * @useinstead ohos.sensor/sensor.SensorId#HEART_RATE 826 */ 827 static subscribeHeartRate(options: SubscribeHeartRateOptions): void; 828 829 /** 830 * Cancels listening to heart rate sensor data. 831 * 832 * @permission ohos.permission.READ_HEALTH_DATA 833 * @syscap SystemCapability.Sensors.Sensor.Lite 834 * @since 3 835 * @deprecated since 8 836 * @useinstead ohos.sensor/sensor.SensorId#HEART_RATE 837 */ 838 static unsubscribeHeartRate(): void; 839 840 /** 841 * Listens to whether a sensor is worn. 842 * If this API is called multiple times, the last call takes effect. 843 * 844 * @param { SubscribeOnBodyStateOptions } options - options Options. 845 * @syscap SystemCapability.Sensors.Sensor.Lite 846 * @since 3 847 * @deprecated since 8 848 * @useinstead ohos.sensor/sensor.SensorId#WEAR_DETECTION 849 */ 850 static subscribeOnBodyState(options: SubscribeOnBodyStateOptions): void; 851 852 /** 853 * Cancels listening to whether the sensor is worn. 854 * 855 * @syscap SystemCapability.Sensors.Sensor.Lite 856 * @since 3 857 * @deprecated since 8 858 * @useinstead ohos.sensor/sensor.SensorId#WEAR_DETECTION 859 */ 860 static unsubscribeOnBodyState(): void; 861 862 /** 863 * Obtains the sensor wearing state. 864 * 865 * @param { GetOnBodyStateOptions } options - options Options. 866 * @syscap SystemCapability.Sensors.Sensor.Lite 867 * @since 3 868 * @deprecated since 8 869 * @useinstead ohos.sensor/sensor.SensorId#WEAR_DETECTION 870 */ 871 static getOnBodyState(options: GetOnBodyStateOptions): void; 872 873 /** 874 * Listens to device orientation sensor data changes. 875 * If this API is called multiple times, the last call takes effect. 876 * 877 * @param { SubscribeDeviceOrientationOptions } options - options Options. 878 * @syscap SystemCapability.Sensors.Sensor.Lite 879 * @since 6 880 * @deprecated since 8 881 * @useinstead ohos.sensor/sensor.SensorId#ORIENTATION 882 */ 883 static subscribeDeviceOrientation(options: SubscribeDeviceOrientationOptions): void; 884 885 /** 886 * Cancels listening to device orientation sensor data. 887 * 888 * @syscap SystemCapability.Sensors.Sensor.Lite 889 * @since 6 890 * @deprecated since 8 891 * @useinstead ohos.sensor/sensor.SensorId#ORIENTATION 892 */ 893 static unsubscribeDeviceOrientation(): void; 894 895 /** 896 * Listens to gyroscope sensor data changes. 897 * If this API is called multiple times, the last call takes effect. 898 * 899 * @permission ohos.permission.GYROSCOPE 900 * @param { SubscribeGyroscopeOptions } options - options Options. 901 * @syscap SystemCapability.Sensors.Sensor.Lite 902 * @since 6 903 * @deprecated since 8 904 * @useinstead ohos.sensor/sensor.SensorId#GYROSCOPE 905 */ 906 static subscribeGyroscope(options: SubscribeGyroscopeOptions): void; 907 908 /** 909 * Cancels listening to gyroscope sensor data. 910 * 911 * @permission ohos.permission.GYROSCOPE 912 * @syscap SystemCapability.Sensors.Sensor.Lite 913 * @since 6 914 * @deprecated since 8 915 * @useinstead ohos.sensor/sensor.SensorId#GYROSCOPE 916 */ 917 static unsubscribeGyroscope(): void; 918}