diff --git a/api/@ohos.sensor.d.ts b/api/@ohos.sensor.d.ts index 6b9946129..c73fd0d78 100644 --- a/api/@ohos.sensor.d.ts +++ b/api/@ohos.sensor.d.ts @@ -21,6 +21,13 @@ import { AsyncCallback, Callback } from './@ohos.base'; * @syscap SystemCapability.Sensors.Sensor * @since 8 */ +/** + * This module provides the capability to subscribe to sensor data. + * @namespace sensor + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ declare namespace sensor { /** * Enum for obtain the type of sensor. @@ -34,6 +41,12 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 9 */ + /** + * Acceleration sensor. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ ACCELEROMETER = 1, /** @@ -41,6 +54,12 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 9 */ + /** + * Gyroscope sensor. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ GYROSCOPE = 2, /** @@ -106,6 +125,12 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 9 */ + /** + * Orientation sensor. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ ORIENTATION = 256, /** @@ -231,6 +256,19 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 9 */ + /** + * Subscribe to accelerometer sensor data. + * @permission ohos.permission.ACCELEROMETER + * @param { SensorId.ACCELEROMETER } type - Indicate the sensor type to listen for, {@code SensorId.ACCELEROMETER}. + * @param { Callback } callback - callback accelerometer data. + * @param { Options } [options] - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 14500101 - Service exception. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ function on(type: SensorId.ACCELEROMETER, callback: Callback, options?: Options): void; @@ -311,6 +349,19 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 9 */ + /** + * Subscribe to gyroscope sensor data. + * @permission ohos.permission.GYROSCOPE + * @param { SensorId.GYROSCOPE } type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE}. + * @param { Callback } callback - callback gyroscope data. + * @param { Options } [options] - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 14500101 - Service exception. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ function on(type: SensorId.GYROSCOPE, callback: Callback, options?: Options): void; @@ -421,6 +472,17 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 9 */ + /** + * Subscribe to orientation sensor data. + * @param { SensorId.ORIENTATION } type - Indicate the sensor type to listen for, {@code SensorId.ORIENTATION}. + * @param { Callback } callback - callback orientation data. + * @param { Options } [options] - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 14500101 - Service exception. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ function on(type: SensorId.ORIENTATION, callback: Callback, options?: Options): void; @@ -785,6 +847,17 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 9 */ + /** + * Unsubscribe to accelerometer sensor data. + * @permission ohos.permission.ACCELEROMETER + * @param { SensorId.ACCELEROMETER } type - Indicate the sensor type to listen for, {@code SensorId.ACCELEROMETER}. + * @param { Callback } callback - callback accelerometer data. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ function off(type: SensorId.ACCELEROMETER, callback?: Callback): void; /** @@ -850,6 +923,17 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 9 */ + /** + * Unsubscribe to gyroscope sensor data. + * @permission ohos.permission.GYROSCOPE + * @param { SensorId.GYROSCOPE } type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE}. + * @param { Callback } callback - callback gyroscope data. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ function off(type: SensorId.GYROSCOPE, callback?: Callback): void; /** @@ -937,6 +1021,15 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 9 */ + /** + * Unsubscribe to orientation sensor data. + * @param { SensorId.ORIENTATION } type - Indicate the sensor type to listen for, {@code SensorId.ORIENTATION}. + * @param { Callback } callback - callback orientation data. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ function off(type: SensorId.ORIENTATION, callback?: Callback): void; /** @@ -2196,7 +2289,7 @@ declare namespace sensor { function getInclination(inclinationMatrix: Array): Promise; /** - * Get the angle change between two rotation matrices + * Get the angle change between two rotation matrices. * @param { Array } currentRotationMatrix - Indicates the current rotation matrix. * @param { Array } preRotationMatrix - Indicates the current rotation matrix. * @param { AsyncCallback> } callback - callback angle variation. @@ -2209,7 +2302,7 @@ declare namespace sensor { callback: AsyncCallback>): void; /** - * Get the angle change between two rotation matrices + * Get the angle change between two rotation matrices. * @param { Array } currentRotationMatrix - currentRotationMatrix Indicates the current rotation matrix. * @param { Array } preRotationMatrix - preRotationMatrix Indicates the current rotation matrix. * @returns { Promise> } Returns the array of number(z, x and y) in which the angle variety. @@ -2312,7 +2405,7 @@ declare namespace sensor { } /** - * Rotate the provided rotation matrix so that it can be represented in a different way Coordinate System + * Rotate the provided rotation matrix so that it can be represented in a different way Coordinate System. * @param { Array } inRotationVector - Indicates the rotation matrix to be transformed. * @param { CoordinatesOptions } coordinates - Indicates coordinate system guidance, {@code CoordinatesOptions}. * @param { AsyncCallback> } callback - callback rotation matrix. @@ -2325,7 +2418,7 @@ declare namespace sensor { callback: AsyncCallback>): void; /** - * Rotate the provided rotation matrix so that it can be represented in a different way Coordinate System + * Rotate the provided rotation matrix so that it can be represented in a different way Coordinate System. * @param { Array } inRotationVector - inRotationVector Indicates the rotation matrix to be transformed. * @param { CoordinatesOptions } coordinates - coordinates Indicates coordinate system guidance, {@code CoordinatesOptions}. * @returns { Promise> } Returns the transformed rotation matrix. @@ -2527,16 +2620,38 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * Subscribe to the sensor's optional parameters. + * @typedef Options + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ interface Options { /** - * Sensor event reporting event interval + * Sensor event reporting event interval. * @type { ?number } * @syscap SystemCapability.Sensors.Sensor * @since 8 */ - interval?: number; + /** + * Sensor event reporting event interval. + * @type {?(number | SensorFrequency) } + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ + interval?: number | SensorFrequency; } + /** + * The sensor reporting frequency is divided into three modes. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ + type SensorFrequency = 'game' | 'ui' | 'normal'; + /** * The type of number. * @enum { number } @@ -2555,7 +2670,7 @@ declare namespace sensor { SENSOR_TYPE_ID_ACCELEROMETER = 1, /** - * Gyroscope sensor + * Gyroscope sensor. * @syscap SystemCapability.Sensors.Sensor * @since 8 * @deprecated since 9 @@ -2619,7 +2734,7 @@ declare namespace sensor { SENSOR_TYPE_ID_ORIENTATION = 256, /** - * Gravity sensor. + * Gravity sensor. * @syscap SystemCapability.Sensors.Sensor * @since 8 * @deprecated since 9 @@ -2719,12 +2834,14 @@ declare namespace sensor { * Enumerates the accuracy levels of data reported by a sensor. * @enum { number } * @syscap SystemCapability.Sensors.Sensor + * @atomicservice * @since 11 */ enum SensorAccuracy { /** * The sensor data is unreliable. It is possible that the sensor does not contact with the device to measure. * @syscap SystemCapability.Sensors.Sensor + * @atomicservice * @since 11 */ ACCURACY_UNRELIABLE = 0, @@ -2732,6 +2849,7 @@ declare namespace sensor { /** * The sensor data is at a low accuracy level. The data must be calibrated based on the environment before being used. * @syscap SystemCapability.Sensors.Sensor + * @atomicservice * @since 11 */ ACCURACY_LOW = 1, @@ -2739,6 +2857,7 @@ declare namespace sensor { /** * The sensor data is at a medium accuracy level. You are advised to calibrate the data based on the environment before using it. * @syscap SystemCapability.Sensors.Sensor + * @atomicservice * @since 11 */ ACCURACY_MEDIUM = 2, @@ -2746,6 +2865,7 @@ declare namespace sensor { /** * The sensor data is at a high accuracy level. The data can be used directly. * @syscap SystemCapability.Sensors.Sensor + * @atomicservice * @since 11 */ ACCURACY_HIGH = 3 @@ -2757,19 +2877,34 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * The basic data structure of the sensor event. + * @typedef Response + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ interface Response { /** - * The timestamp of the reported sensor data + * The timestamp of the reported sensor data. * @type { number } * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * The timestamp of the reported sensor data. + * @type { number } + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ timestamp: number; /** * The accuracy levels of data reported by a sensor. * @type { SensorAccuracy } * @syscap SystemCapability.Sensors.Sensor + * @atomicservice * @since 11 */ accuracy: SensorAccuracy; @@ -2781,6 +2916,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * Acceleration sensor event data. + * @typedef AccelerometerResponse + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ interface AccelerometerResponse extends Response { /** * Acceleration x-axis component. @@ -2788,6 +2930,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * Acceleration x-axis component. + * @type { number } + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ x: number; /** @@ -2796,6 +2945,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * Acceleration y-axis component. + * @type { number } + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ y: number; /** @@ -2804,6 +2960,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * Acceleration z-axis component + * @type { number } + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ z: number; } @@ -2815,7 +2978,7 @@ declare namespace sensor { */ interface LinearAccelerometerResponse extends Response { /** - * Linear acceleration x-axis component + * Linear acceleration x-axis component. * @type { number } * @syscap SystemCapability.Sensors.Sensor * @since 8 @@ -2823,7 +2986,7 @@ declare namespace sensor { x: number; /** - * Linear acceleration y-axis component + * Linear acceleration y-axis component. * @type { number } * @syscap SystemCapability.Sensors.Sensor * @since 8 @@ -2831,7 +2994,7 @@ declare namespace sensor { y: number; /** - * Linear acceleration z-axis component + * Linear acceleration z-axis component. * @type { number } * @syscap SystemCapability.Sensors.Sensor * @since 8 @@ -2880,7 +3043,7 @@ declare namespace sensor { biasX: number; /** - * Acceleration uncalibrated y-axis offset + * Acceleration uncalibrated y-axis offset. * * @type { number } * @syscap SystemCapability.Sensors.Sensor @@ -2889,7 +3052,7 @@ declare namespace sensor { biasY: number; /** - * Acceleration uncalibrated z-axis offset + * Acceleration uncalibrated z-axis offset. * * @type { number } * @syscap SystemCapability.Sensors.Sensor @@ -2936,6 +3099,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * Orientation sensor event data. + * @typedef OrientationResponse + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ interface OrientationResponse extends Response { /** * The device rotates at an angle around the Z axis. @@ -2943,6 +3113,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * The device rotates at an angle around the Z axis. + * @type { number } + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ alpha: number; /** @@ -2951,6 +3128,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * The device rotates at an angle around the X axis. + * @type { number } + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ beta: number; /** @@ -2959,6 +3143,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * The device rotates at an angle around the Y axis. + * @type { number } + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ gamma: number; } @@ -3008,6 +3199,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * Gyroscope sensor event data. + * @typedef GyroscopeResponse + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ interface GyroscopeResponse extends Response { /** * Gyroscope x-axis component. @@ -3015,6 +3213,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * Gyroscope x-axis component. + * @type { number } + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ x: number; /** @@ -3023,6 +3228,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * Gyroscope y-axis component. + * @type { number } + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ y: number; /** @@ -3031,6 +3243,13 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ + /** + * Gyroscope z-axis component. + * @type { number } + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 11 + */ z: number; } @@ -3284,7 +3503,8 @@ declare namespace sensor { */ interface PedometerDetectionResponse extends Response { /** - * Indicates the pedometer detection status, 1 indicates that a walking action has occurred, and 0 indicates that no movement has occurred. + * Indicates the pedometer detection status, 1 indicates that a walking action has occurred, + * and 0 indicates that no movement has occurred. * @type { number } * @syscap SystemCapability.Sensors.Sensor * @since 8 diff --git a/build-tools/api_check_plugin/plugin/dictionaries.txt b/build-tools/api_check_plugin/plugin/dictionaries.txt index b5aaba5c1..b4367a6ef 100644 --- a/build-tools/api_check_plugin/plugin/dictionaries.txt +++ b/build-tools/api_check_plugin/plugin/dictionaries.txt @@ -29074,6 +29074,7 @@ hoydenish hoyle hoyt hp +hpa hpp hq hql