From d5147d40af02c6296d0483605774d0a50911c67b Mon Sep 17 00:00:00 2001 From: h00514358 Date: Wed, 31 Aug 2022 09:55:34 +0800 Subject: [PATCH 1/2] API interface exception handling Signed-off-by: h00514358 --- api/@ohos.sensor.d.ts | 1121 +++++++++++++++++++++++++++++++++++---- api/@ohos.vibrator.d.ts | 94 ++++ 2 files changed, 1119 insertions(+), 96 deletions(-) diff --git a/api/@ohos.sensor.d.ts b/api/@ohos.sensor.d.ts index 696c80a977..93869b669b 100644 --- a/api/@ohos.sensor.d.ts +++ b/api/@ohos.sensor.d.ts @@ -22,6 +22,809 @@ import { AsyncCallback, Callback } from "./basic"; * @import import sensor from '@ohos.sensor' */ declare namespace sensor { + /** + * The error code of sensor. + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + enum ErrorCode { + /* Indicates input parameter range error.*/ + INPUT_PARAM_ERROR = 14500101, + /* Indicates connect sensors service fail.*/ + CONNECT_SERVICE_FAIL = 14500102, + /* Indicates that the device does not support subscribe the sensor.*/ + SENSOR_NOT_EXIST = 14500103, + /* Indicates that unsubscribe sensor failed, you should subscribe first.*/ + UNSUBSCRIBE_FAIL = 14500104 + } + /** + * The type of sensor. + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + enum SensorId { + ACCELEROMETER = 1, /**< Acceleration sensor */ + GYROSCOPE = 2, /**< Gyroscope sensor */ + AMBIENT_LIGHT = 5, /**< Ambient light sensor */ + MAGNETIC_FIELD = 6, /**< Magnetic field sensor */ + BAROMETER = 8, /**< Barometric pressure sensor */ + HALL = 10, /**< Hall effect sensor */ + PROXIMITY = 12, /**< Proximity sensor */ + HUMIDITY = 13, /**< Humidity sensor */ + ORIENTATION = 256, /**< Orientation sensor */ + GRAVITY = 257, /**< Gravity sensor */ + LINEAR_ACCELERATION = 258, /**< Linear acceleration sensor */ + ROTATION_VECTOR = 259, /**< Rotation vector sensor */ + AMBIENT_TEMPERATURE = 260, /**< Ambient temperature sensor */ + MAGNETIC_FIELD_UNCALIBRATED = 261, /**< Uncalibrated magnetic field sensor */ + GYROSCOPE_UNCALIBRATED = 263, /**< Uncalibrated gyroscope sensor */ + SIGNIFICANT_MOTION = 264, /**< Significant motion sensor */ + PEDOMETER_DETECTION = 265, /**< Pedometer detection sensor */ + PEDOMETER = 266, /**< Pedometer sensor */ + HEART_RATE = 278, /**< Heart rate sensor */ + WEAR_DETECTION = 280, /**< Wear detection sensor */ + ACCELEROMETER_UNCALIBRATED = 281 /**< Uncalibrated acceleration sensor */ + } + + /** + * Subscribe to accelerometer sensor data. + * @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 {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.ACCELEROMETER, callback: Callback, + options?: Options): void; + + /** + * Subscribe to uncalibrated accelerometer sensor data. + * @param {SensorId.ACCELEROMETER_UNCALIBRATED} type - Indicate the sensor type to listen for, + * {@code SensorId.ACCELEROMETER_UNCALIBRATED}. + * @param {Callback} callback - callback uncalibrated accelerometer data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback, + options?: Options): void; + + /** + * Subscribe to ambient light sensor data. + * @param {SensorId.AMBIENT_LIGHT} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_LIGHT}. + * @param {Callback} callback - callback ambient data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.AMBIENT_LIGHT, callback: Callback, options?: Options): void; + + /** + * Subscribe to ambient temperature sensor data. + * @param {SensorId.AMBIENT_TEMPERATURE} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_TEMPERATURE}. + * @param {Callback} callback - callback temperature data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback, + options?: Options): void; + + /** + * Subscribe to barometer sensor data. + * @param {SensorId.BAROMETER} type - Indicate the sensor type to listen for, {@code SensorId.BAROMETER}. + * @param {Callback} callback - callback barometer data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.BAROMETER, callback: Callback, options?: Options): void; + + /** + * Subscribe to gravity sensor data. + * @param {SensorId.GRAVITY} type - Indicate the sensor type to listen for, {@code SensorId.GRAVITY}. + * @param {Callback} callback - callback gravity data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.GRAVITY, callback: Callback, + options?: Options): void; + + /** + * Subscribe to gyroscope sensor data. + * @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 {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.GYROSCOPE, callback: Callback, + options?: Options): void; + + /** + * Subscribe to uncalibrated gyroscope sensor data. + * @param {SensorId.GYROSCOPE_UNCALIBRATED} type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE_UNCALIBRATED}. + * @param {Callback} callback - callback uncalibrated gyroscope data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback, + options?: Options): void; + + /** + * Subscribe to hall sensor data. + * @param {SensorId.HALL} type - Indicate the sensor type to listen for, {@code SensorId.HALL}. + * @param {Callback} callback - callback uncalibrated gyroscope data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.HALL, callback: Callback, options?: Options): void; + + /** + * Subscribe to heart rate sensor data. + * @param {SensorId.HEART_RATE} type - Indicate the sensor type to listen for, {@code SensorId.HEART_RATE}. + * @param {Callback} callback - callback heart rate data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.READ_HEALTH_DATA + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.HEART_RATE, callback: Callback, + options?: Options): void; + + /** + * Subscribe to humidity sensor data. + * @param {SensorId.HUMIDITY} type - Indicate the sensor type to listen for, {@code SensorId.HUMIDITY}. + * @param {Callback} callback - callback humidity data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.HUMIDITY, callback: Callback, + options?: Options): void; + + /** + * Subscribe to linear acceleration sensor data. + * @param {SensorId.LINEAR_ACCELERATION} type - Indicate the sensor type to listen for, {@code SensorId.LINEAR_ACCELERATION}. + * @param {Callback} callback - callback linear acceleration data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.LINEAR_ACCELERATION, callback: Callback, + options?: Options): void; + + /** + * Subscribe to magnetic field sensor data. + * @param {SensorId.MAGNETIC_FIELD} type - Indicate the sensor type to listen for, {@code SensorId.MAGNETIC_FIELD}. + * @param {Callback} callback - callback magnetic field data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.MAGNETIC_FIELD, callback: Callback, + options?: Options): void; + + /** + * Subscribe to uncalibrated magnetic field sensor data. + * @param {SensorId.MAGNETIC_FIELD_UNCALIBRATED} type - Indicate the sensor type to listen for, + * {@code SensorId.MAGNETIC_FIELD_UNCALIBRATED}. + * @param {Callback} callback - callback uncalibrated magnetic field data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback, + options?: Options): void; + + /** + * 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 {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.ORIENTATION, callback: Callback, + options?: Options): void; + + /** + * Subscribe to pedometer sensor data. + * @param {SensorId.PEDOMETER} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER}. + * @param {Callback} callback - callback pedometer data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACTIVITY_MOTION + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.PEDOMETER, callback: Callback, options?: Options): void; + + /** + * Subscribe to pedometer detection sensor data. + * @param {SensorId.PEDOMETER_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER_DETECTION}. + * @param {Callback} callback - callback pedometer detection data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACTIVITY_MOTION + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.PEDOMETER_DETECTION, callback: Callback, + options?: Options): void; + + /** + * Subscribe to proximity sensor data. + * @param {SensorId.PROXIMITY} type - Indicate the sensor type to listen for, {@code SensorId.PROXIMITY}. + * @param {Callback} callback - callback proximity data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.PROXIMITY, callback: Callback, options?: Options): void; + + /** + * Subscribe to rotation vector sensor data. + * @param {SensorId.ROTATION_VECTOR} type - Indicate the sensor type to listen for, {@code SensorId.ROTATION_VECTOR}. + * @param {Callback} callback - callback rotation vector data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.ROTATION_VECTOR, callback: Callback, + options?: Options): void; + + /** + * Subscribe to significant motion sensor data. + * @param {SensorId.SIGNIFICANT_MOTION} type - Indicate the sensor type to listen for, {@code SensorId.SIGNIFICANT_MOTION}. + * @param {Callback} callback - callback significant motion data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.SIGNIFICANT_MOTION, callback: Callback, + options?: Options): void; + + /** + * Subscribe to wear detection sensor data. + * @param {SensorId.WEAR_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.WEAR_DETECTION}. + * @param {Callback} callback - callback wear detection data. + * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function on(type: SensorId.WEAR_DETECTION, callback: Callback, + options?: Options): void; + + /** + * Subscribe to accelerometer sensor data once. + * @param {SensorId.ACCELEROMETER} type - Indicate the sensor type to listen for, {@code SensorId.ACCELEROMETER}. + * @param {Callback} callback - callback accelerometer data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.ACCELEROMETER, callback: Callback): void; + + /** + * Subscribe to uncalibrated accelerometer sensor data once. + * @param {SensorId.ACCELEROMETER_UNCALIBRATED} type - Indicate the sensor type to listen for, + * {@code SensorId.ACCELEROMETER_UNCALIBRATED}. + * @param {Callback} callback - callback uncalibrated accelerometer data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback): void; + + /** + * Subscribe to ambient light sensor data once. + * @param {SensorId.AMBIENT_LIGHT} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_LIGHT}. + * @param {Callback} callback - callback ambient data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.AMBIENT_LIGHT, callback: Callback): void; + + /** + * Subscribe to ambient temperature sensor data once. + * @param {SensorId.AMBIENT_TEMPERATURE} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_TEMPERATURE}. + * @param {Callback} callback - callback temperature data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback): void; + + /** + * Subscribe to barometer sensor data once. + * @param {SensorId.BAROMETER} type - Indicate the sensor type to listen for, {@code SensorId.BAROMETER}. + * @param {Callback} callback - callback barometer data. + + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.BAROMETER, callback: Callback): void; + + /** + * Subscribe to gravity sensor data once. + * @param {SensorId.GRAVITY} type - Indicate the sensor type to listen for, {@code SensorId.GRAVITY}. + * @param {Callback} callback - callback gravity data. + + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.GRAVITY, callback: Callback): void; + + /** + * Subscribe to gyroscope sensor data once. + * @param {SensorId.GYROSCOPE} type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE}. + * @param {Callback} callback - callback gyroscope data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.GYROSCOPE, callback: Callback): void; + + /** + * Subscribe to uncalibrated gyroscope sensor data once. + * @param {SensorId.GYROSCOPE_UNCALIBRATED} type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE_UNCALIBRATED}. + * @param {Callback} callback - callback uncalibrated gyroscope data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback): void; + + /** + * Subscribe to hall sensor data once. + * @param {SensorId.HALL} type - Indicate the sensor type to listen for, {@code SensorId.HALL}. + * @param {Callback} callback - callback uncalibrated gyroscope data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.HALL, callback: Callback): void; + + /** + * Subscribe to heart rate sensor data once. + * @param {SensorId.HEART_RATE} type - Indicate the sensor type to listen for, {@code SensorId.HEART_RATE}. + * @param {Callback} callback - callback heart rate data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.READ_HEALTH_DATA + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.HEART_RATE, callback: Callback): void; + + /** + * Subscribe to humidity sensor data once. + * @param {SensorId.HUMIDITY} type - Indicate the sensor type to listen for, {@code SensorId.HUMIDITY}. + * @param {Callback} callback - callback humidity data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.HUMIDITY, callback: Callback): void; + + /** + * Subscribe to linear acceleration sensor data once. + * @param {SensorId.LINEAR_ACCELERATION} type - Indicate the sensor type to listen for, {@code SensorId.LINEAR_ACCELERATION}. + * @param {Callback} callback - callback linear acceleration data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.LINEAR_ACCELERATION, callback: Callback): void; + + /** + * Subscribe to magnetic field sensor data once. + * @param {SensorId.MAGNETIC_FIELD} type - Indicate the sensor type to listen for, {@code SensorId.MAGNETIC_FIELD}. + * @param {Callback} callback - callback magnetic field data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.MAGNETIC_FIELD, callback: Callback): void; + + /** + * Subscribe to uncalibrated magnetic field sensor data once. + * @param {SensorId.MAGNETIC_FIELD_UNCALIBRATED} type - Indicate the sensor type to listen for, + * {@code SensorId.MAGNETIC_FIELD_UNCALIBRATED}. + * @param {Callback} callback - callback uncalibrated magnetic field data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback): void; + + /** + * Subscribe to orientation sensor data once. + * @param {SensorId.ORIENTATION} type - Indicate the sensor type to listen for, {@code SensorId.ORIENTATION}. + * @param {Callback} callback - callback orientation data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.ORIENTATION, callback: Callback): void; + + /** + * Subscribe to pedometer sensor data once. + * @param {SensorId.PEDOMETER} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER}. + * @param {Callback} callback - callback pedometer data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACTIVITY_MOTION + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.PEDOMETER, callback: Callback): void; + + /** + * Subscribe to pedometer detection sensor data once. + * @param {SensorId.PEDOMETER_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER_DETECTION}. + * @param {Callback} callback - callback pedometer detection data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACTIVITY_MOTION + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.PEDOMETER_DETECTION, callback: Callback): void; + + /** + * Subscribe to proximity sensor data once. + * @param {SensorId.PROXIMITY} type - Indicate the sensor type to listen for, {@code SensorId.PROXIMITY}. + * @param {Callback} callback - callback proximity data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.PROXIMITY, callback: Callback): void; + + /** + * Subscribe to rotation vector sensor data once. + * @param {SensorId.ROTATION_VECTOR} type - Indicate the sensor type to listen for, {@code SensorId.ROTATION_VECTOR}. + * @param {Callback} callback - callback rotation vector data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.ROTATION_VECTOR, callback: Callback): void; + + + /** + * Subscribe to significant motion sensor data once. + * @param {SensorId.SIGNIFICANT_MOTION} type - Indicate the sensor type to listen for, {@code SensorId.SIGNIFICANT_MOTION}. + * @param {Callback} callback - callback significant motion data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.SIGNIFICANT_MOTION, callback: Callback): void; + + /** + * Subscribe to wear detection sensor data once. + * @param {SensorId.WEAR_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.WEAR_DETECTION}. + * @param {Callback} callback - callback wear detection data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function once(type: SensorId.WEAR_DETECTION, callback: Callback): void; + /** + * Unsubscribe to accelerometer sensor data. + * @param {SensorId.ACCELEROMETER} type - Indicate the sensor type to listen for, {@code SensorId.ACCELEROMETER}. + * @param {Callback} callback - callback accelerometer data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.ACCELEROMETER, callback?: Callback): void; + + /** + * Unsubscribe to uncalibrated accelerometer sensor data. + * @param {SensorId.ACCELEROMETER_UNCALIBRATED} type - Indicate the sensor type to listen for, + * {@code SensorId.ACCELEROMETER_UNCALIBRATED}. + * @param {Callback} callback - callback uncalibrated accelerometer data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback?: Callback): void; + + /** + * Unsubscribe to ambient light sensor data. + * @param {SensorId.AMBIENT_LIGHT} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_LIGHT}. + * @param {Callback} callback - callback ambient data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.AMBIENT_LIGHT, callback?: Callback): void; + + /** + * Unsubscribe to ambient temperature sensor data. + * @param {SensorId.AMBIENT_TEMPERATURE} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_TEMPERATURE}. + * @param {Callback} callback - callback temperature data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.AMBIENT_TEMPERATURE, callback?: Callback): void; + + /** + * Unsubscribe to barometer sensor data. + * @param {SensorId.BAROMETER} type - Indicate the sensor type to listen for, {@code SensorId.BAROMETER}. + * @param {Callback} callback - callback barometer data. + + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.BAROMETER, callback?: Callback): void; + + /** + * Unsubscribe to gravity sensor data. + * @param {SensorId.GRAVITY} type - Indicate the sensor type to listen for, {@code SensorId.GRAVITY}. + * @param {Callback} callback - callback gravity data. + + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.GRAVITY, callback?: Callback): void; + + /** + * Unsubscribe to gyroscope sensor data. + * @param {SensorId.GYROSCOPE} type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE}. + * @param {Callback} callback - callback gyroscope data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.GYROSCOPE, callback?: Callback): void; + + /** + * Unsubscribe to uncalibrated gyroscope sensor data. + * @param {SensorId.GYROSCOPE_UNCALIBRATED} type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE_UNCALIBRATED}. + * @param {Callback} callback - callback uncalibrated gyroscope data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.GYROSCOPE_UNCALIBRATED, callback?: Callback): void; + + /** + * Unsubscribe to hall sensor data. + * @param {SensorId.HALL} type - Indicate the sensor type to listen for, {@code SensorId.HALL}. + * @param {Callback} callback - callback uncalibrated gyroscope data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.HALL, callback?: Callback): void; + + /** + * Unsubscribe to heart rate sensor data. + * @param {SensorId.HEART_RATE} type - Indicate the sensor type to listen for, {@code SensorId.HEART_RATE}. + * @param {Callback} callback - callback heart rate data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.READ_HEALTH_DATA + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.HEART_RATE, callback?: Callback): void; + + /** + * Unsubscribe to humidity sensor data. + * @param {SensorId.HUMIDITY} type - Indicate the sensor type to listen for, {@code SensorId.HUMIDITY}. + * @param {Callback} callback - callback humidity data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.HUMIDITY, callback?: Callback): void; + + /** + * Unsubscribe to linear acceleration sensor data. + * @param {SensorId.LINEAR_ACCELERATION} type - Indicate the sensor type to listen for, {@code SensorId.LINEAR_ACCELERATION}. + * @param {Callback} callback - callback linear acceleration data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.LINEAR_ACCELERATION, callback?: Callback): void; + + /** + * Unsubscribe to magnetic field sensor data. + * @param {SensorId.MAGNETIC_FIELD} type - Indicate the sensor type to listen for, {@code SensorId.MAGNETIC_FIELD}. + * @param {Callback} callback - callback magnetic field data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.MAGNETIC_FIELD, callback?: Callback): void; + + /** + * Unsubscribe to uncalibrated magnetic field sensor data. + * @param {SensorId.MAGNETIC_FIELD_UNCALIBRATED} type - Indicate the sensor type to listen for, + * {@code SensorId.MAGNETIC_FIELD_UNCALIBRATED}. + * @param {Callback} callback - callback uncalibrated magnetic field data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback): void; + + /** + * 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 {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.ORIENTATION, callback?: Callback): void; + + /** + * Unsubscribe to pedometer sensor data. + * @param {SensorId.PEDOMETER} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER}. + * @param {Callback} callback - callback pedometer data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACTIVITY_MOTION + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.PEDOMETER, callback?: Callback): void; + + /** + * Unsubscribe to pedometer detection sensor data. + * @param {SensorId.PEDOMETER_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER_DETECTION}. + * @param {Callback} callback - callback pedometer detection data. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.ACTIVITY_MOTION + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.PEDOMETER_DETECTION, callback?: Callback): void; + + /** + * Unsubscribe to proximity sensor data. + * @param {SensorId.PROXIMITY} type - Indicate the sensor type to listen for, {@code SensorId.PROXIMITY}. + * @param {Callback} callback - callback proximity data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.PROXIMITY, callback?: Callback): void; + + /** + * Unsubscribe to rotation vector sensor data. + * @param {SensorId.ROTATION_VECTOR} type - Indicate the sensor type to listen for, {@code SensorId.ROTATION_VECTOR}. + * @param {Callback} callback - callback rotation vector data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.ROTATION_VECTOR, callback?: Callback): void; + + + /** + * Unsubscribe to significant motion sensor data. + * @param {SensorId.SIGNIFICANT_MOTION} type - Indicate the sensor type to listen for, {@code SensorId.SIGNIFICANT_MOTION}. + * @param {Callback} callback - callback significant motion data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.SIGNIFICANT_MOTION, callback?: Callback): void; + + /** + * Unsubscribe to wear detection sensor data. + * @param {SensorId.WEAR_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.WEAR_DETECTION}. + * @param {Callback} callback - callback wear detection data. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function off(type: SensorId.WEAR_DETECTION, callback?: Callback): void; + /** * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_ACCELEROMETER}. @@ -29,6 +832,7 @@ declare namespace sensor { * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback, options?: Options): void; @@ -40,6 +844,7 @@ declare namespace sensor { * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback: Callback, options?: Options): void; @@ -50,6 +855,7 @@ declare namespace sensor { * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback, options?: Options): void; @@ -60,6 +866,7 @@ declare namespace sensor { * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback: Callback, options?: Options): void; @@ -70,6 +877,7 @@ declare namespace sensor { * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback, options?: Options): void; @@ -80,6 +888,7 @@ declare namespace sensor { * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback, options?: Options): void; @@ -91,6 +900,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.GYROSCOPE * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback, options?: Options): void; @@ -102,6 +912,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.GYROSCOPE * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback: Callback, options?: Options): void; @@ -112,6 +923,7 @@ declare namespace sensor { * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback, options?: Options): void; @@ -124,28 +936,17 @@ declare namespace sensor { * @permission ohos.permission.HEALTH_DATA * @since 8 * @deprecated since 9 - * @useinstead SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE */ function on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback, options?: Options): void; - /** - * Subscribe to heart rate sensor data. - * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE}. - * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @syscap SystemCapability.Sensors.Sensor - * @permission ohos.permission.READ_HEALTH_DATA - * @since 9 - */ - function on(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback: Callback, - options?: Options): void; - /** * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HUMIDITY}. * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback, options?: Options): void; @@ -158,28 +959,17 @@ declare namespace sensor { * @permission ohos.permission.ACCELEROMETER * @since 8 * @deprecated since 9 - * @useinstead SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER */ function on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback: Callback, options?: Options): void; - /** - * Subscribe to linear accelerometer data. - * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER}. - * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @syscap SystemCapability.Sensors.Sensor - * @permission ohos.permission.ACCELEROMETER - * @since 9 - */ - function on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback: Callback, - options?: Options): void; - /** * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD}. * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback, options?: Options): void; @@ -190,6 +980,7 @@ declare namespace sensor { * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback: Callback, options?: Options): void; @@ -200,6 +991,7 @@ declare namespace sensor { * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback, options?: Options): void; @@ -211,6 +1003,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.ACTIVITY_MOTION * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback, options?: Options): void; @@ -222,6 +1015,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.ACTIVITY_MOTION * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback, options?: Options): void; @@ -232,6 +1026,7 @@ declare namespace sensor { * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback, options?: Options): void; @@ -242,6 +1037,7 @@ declare namespace sensor { * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback, options?: Options): void; @@ -252,6 +1048,7 @@ declare namespace sensor { * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback, options?: Options): void; @@ -262,6 +1059,7 @@ declare namespace sensor { * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback, options?: Options): void; @@ -272,6 +1070,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.ACCELEROMETER * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback): void; @@ -281,6 +1080,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.ACCELEROMETER * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback: Callback): void; @@ -289,6 +1089,7 @@ declare namespace sensor { * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback): void; @@ -297,6 +1098,7 @@ declare namespace sensor { * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback: Callback): void; @@ -305,6 +1107,7 @@ declare namespace sensor { * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_BAROMETER}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback): void; @@ -313,6 +1116,7 @@ declare namespace sensor { * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_GRAVITY}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback): void; @@ -322,6 +1126,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.GYROSCOPE * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback): void; @@ -331,6 +1136,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.GYROSCOPE * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback: Callback): void; @@ -339,6 +1145,7 @@ declare namespace sensor { * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HALL}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback): void; @@ -349,24 +1156,15 @@ declare namespace sensor { * @permission ohos.permission.HEART_RATE * @since 8 * @deprecated since 9 - * @useinstead SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE */ function once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback): void; - /** - * Subscribe to heart rate sensor data once. - * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE}. - * @syscap SystemCapability.Sensors.Sensor - * @permission ohos.permission.READ_HEALTH_DATA - * @since 9 - */ - function once(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback: Callback): void; - /** * Subscribe to sensor data once. * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HUMIDITY}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback): void; @@ -377,24 +1175,15 @@ declare namespace sensor { * @permission ohos.permission.ACCELERATION * @since 8 * @deprecated since 9 - * @useinstead SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER */ function once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback: Callback): void; - /** - * Subscribe to sensor data once. - * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER}. - * @syscap SystemCapability.Sensors.Sensor - * @permission ohos.permission.ACCELEROMETER - * @since 9 - */ - function once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback: Callback): void; - /** * Subscribe to sensor data once. * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback): void; @@ -403,6 +1192,7 @@ declare namespace sensor { * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback: Callback): void; @@ -411,6 +1201,7 @@ declare namespace sensor { * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_ORIENTATION}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback): void; @@ -420,6 +1211,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.ACTIVITY_MOTION * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback): void; @@ -429,6 +1221,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.ACTIVITY_MOTION * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback): void; @@ -437,6 +1230,7 @@ declare namespace sensor { * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_PROXIMITY}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback): void; @@ -445,6 +1239,7 @@ declare namespace sensor { * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback): void; @@ -453,6 +1248,7 @@ declare namespace sensor { * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback): void; @@ -461,6 +1257,7 @@ declare namespace sensor { * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_WEAR_DETECTION}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback): void; @@ -470,6 +1267,7 @@ declare namespace sensor { * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback): void; @@ -479,6 +1277,7 @@ declare namespace sensor { * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback): void; @@ -488,6 +1287,7 @@ declare namespace sensor { * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback): void; @@ -496,6 +1296,7 @@ declare namespace sensor { * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback): void; @@ -504,6 +1305,7 @@ declare namespace sensor { * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_BAROMETER}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback): void; @@ -512,6 +1314,7 @@ declare namespace sensor { * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_GRAVITY}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback): void; @@ -521,6 +1324,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.GYROSCOPE * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback): void; @@ -530,6 +1334,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.GYROSCOPE * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback): void; @@ -538,6 +1343,7 @@ declare namespace sensor { * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_HALL}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback): void; @@ -548,25 +1354,15 @@ declare namespace sensor { * @permission ohos.permission.HEALTH_DATA * @since 8 * @deprecated since 9 - * @useinstead SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE */ function off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback): void; - /** - * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. - * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE}. - * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @syscap SystemCapability.Sensors.Sensor - * @permission ohos.permission.READ_HEALTH_DATA - * @since 9 - */ - function off(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback?: Callback): void; - /** * Unsubscribe to sensor data. * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_HUMIDITY}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback): void; @@ -577,24 +1373,15 @@ declare namespace sensor { * @permission ohos.permission.ACCELEROMETER * @since 8 * @deprecated since 9 - * @useinstead SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER */ function off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback): void; - /** - * Unsubscribe to sensor data. - * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER}. - * @syscap SystemCapability.Sensors.Sensor - * @permission ohos.permission.ACCELEROMETER - * @since 9 - */ - function off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback?: Callback): void; - /** * Unsubscribe to sensor data. * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback): void; @@ -603,6 +1390,7 @@ declare namespace sensor { * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback): void; @@ -611,6 +1399,7 @@ declare namespace sensor { * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_ORIENTATION}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback): void; @@ -620,6 +1409,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.ACTIVITY_MOTION * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback): void; @@ -629,6 +1419,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @permission ohos.permission.ACTIVITY_MOTION * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback): void; @@ -637,6 +1428,7 @@ declare namespace sensor { * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_PROXIMITY}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback): void; @@ -645,6 +1437,7 @@ declare namespace sensor { * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback): void; @@ -653,6 +1446,7 @@ declare namespace sensor { * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback): void; @@ -661,6 +1455,7 @@ declare namespace sensor { * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_WEAR_DETECTION}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 */ function off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback): void; @@ -674,28 +1469,39 @@ declare namespace sensor { venderName:string; /**< Sensor vendor */ firmwareVersion:string; /**< Sensor firmware version */ hardwareVersion:string; /**< Sensor hardware version */ - sensorTypeId:number; /**< Sensor type ID, {@code SensorType} */ + SensorId:number; /**< Sensor type ID, {@code SensorType} */ maxRange:number; /**< Maximum measurement range of the sensor */ + minSamplePeriod; /**< Minimum sample period allowed, in ns */ + maxSamplePeriod; /**< maximum sample period allowed, in ns */ precision:number; /**< Sensor accuracy */ power:number; /**< Sensor power */ } - + /** * Obtains the sensor information of a specified type. - * @param type Indicate the sensor type, {@code SensorType}. + * @param type Indicate the sensor type, {@code SensorId}. + * @param {AsyncCallback} callback - callback sensor info. + * @returns {void | Promise} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * * @syscap SystemCapability.Sensors.Sensor * @since 9 */ - function getSingleSensor(type: SensorType, callback: AsyncCallback): void; - function getSingleSensor(type: SensorType): Promise; - + function getSingleSensor(type: SensorId, callback: AsyncCallback): void; + function getSingleSensor(type: SensorId): Promise; + /** * Obtains all sensor information on the device. + * @param type Indicate the sensor type, {@code SensorId}. + * @param {AsyncCallback>} callback - callback sensor list. + * @returns {void | Promise>} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * * @syscap SystemCapability.Sensors.Sensor * @since 9 */ - function getSensorLists(callback: AsyncCallback>): void; - function getSensorLists(): Promise>; + function getSensorList(callback: AsyncCallback>): void; + function getSensorList(): Promise>; /** * Indicates geomagnetic field data. @@ -732,10 +1538,27 @@ declare namespace sensor { * @return Returns the geomagnetic field data, {@code GeomagneticResponse}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 + * @useinstead getGeomagneticInfo, {@code getGeomagneticInfo}. */ function getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback): void; function getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise; + /** + * Obtains the geomagnetic field at a specific location on the Earth. + * @param LocationOptions Indicates geographic location, {@code LocationOptions}. + * @param timeMillis Indicates the time at which the magnetic declination is to be obtained, in milliseconds + * since the Unix epoch. + * @param {AsyncCallback} callback - callback geomagnetic field. + * @returns {void | Promise} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback): void; + function getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number): Promise; + /** * Obtains the altitude at which the device is located based on the current atmospheric pressure. * @@ -744,10 +1567,26 @@ declare namespace sensor { * @return Returns the altitude in meters at which the device is located. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 + * @useinstead getDeviceAltitude, {@code getDeviceAltitude}. */ function getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback): void; function getAltitude(seaPressure: number, currentPressure: number): Promise; + /** + * Obtains the altitude at which the device is located based on the current atmospheric pressure. + * @param seaPressure Indicates the sea level pressure, in hPa. + * @param currentPressure Indicates the atmospheric pressure measured by the barometer, in hPa. + * @param {AsyncCallback} callback - callback device altitude. + * @returns {void | Promise} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function getDeviceAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback): void; + function getDeviceAltitude(seaPressure: number, currentPressure: number): Promise; + /** * Computes the geomagnetic inclination angle in radians from the inclination matrix. * @@ -755,10 +1594,25 @@ declare namespace sensor { * @return Returns the geomagnetic inclination angle in radians. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 + * @useinstead getInclination, {@code getInclination}. */ function getGeomagneticDip(inclinationMatrix: Array, callback: AsyncCallback): void; function getGeomagneticDip(inclinationMatrix: Array): Promise; + /** + * Computes the geomagnetic inclination in radians from the inclination matrix. + * @param inclinationMatrix Indicates the inclination matrix. + * @param {AsyncCallback} callback - callback inclination in radians. + * @returns {void | Promise} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function getInclination(inclinationMatrix: Array, callback: AsyncCallback): void; + function getInclination(inclinationMatrix: Array): Promise; + /** * Get the angle change between two rotation matrices * @@ -767,11 +1621,28 @@ declare namespace sensor { * @return Returns the array of number(z, x and y) in which the angle variety. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 + * @useinstead getAngleVariation, {@code getAngleVariation}. */ function getAngleModify(currentRotationMatrix: Array, preRotationMatrix: Array, callback: AsyncCallback>): void; function getAngleModify(currentRotationMatrix: Array, preRotationMatrix: Array): Promise>; + /** + * Get the angle variation between two rotation matrices. + * @param currentRotationMatrix Indicates the current rotation matrix. + * @param preRotationMatrix Indicates the current rotation matrix. + * @param {AsyncCallback>} callback - callback angle variation. + * @returns {void | Promise>} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function getAngleVariation(currentRotationMatrix: Array, preRotationMatrix: Array, + callback: AsyncCallback>): void; + function getAngleVariation(currentRotationMatrix: Array, preRotationMatrix: Array): Promise>; + /** * Convert rotation vector to rotation matrix. * @@ -779,10 +1650,25 @@ declare namespace sensor { * @return Returns the rotation matrix. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 + * @useinstead getRotationMatrix, {@code getRotationMatrix}. */ function createRotationMatrix(rotationVector: Array, callback: AsyncCallback>): void; function createRotationMatrix(rotationVector: Array): Promise>; + /** + * Convert rotation vector to rotation matrix. + * @param rotationVector Indicates the rotation vector. + * @param {AsyncCallback>} callback - callback rotation matrix. + * @returns {void | Promise>} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function getRotationMatrix(rotationVector: Array, callback: AsyncCallback>): void; + function getRotationMatrix(rotationVector: Array): Promise>; + /** * Indicates the axis of the new coordinate system that coincides with the XY axis of the * original coordinate system. @@ -808,11 +1694,28 @@ declare namespace sensor { * @return Returns the transformed rotation matrix. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 + * @useinstead transformRotationMatrix, {@code transformRotationMatrix}. */ function transformCoordinateSystem(inRotationVector: Array, coordinates: CoordinatesOptions, callback: AsyncCallback>): void; function transformCoordinateSystem(inRotationVector: Array, coordinates: CoordinatesOptions): Promise>; + /** + * Rotate the provided rotation matrix so that it can be represented in a different way coordinate System. + * @param inRotationVector Indicates the rotation matrix to be transformed. + * @param coordinates Indicates coordinate system guidance, {@code CoordinatesOptions}. + * @param {AsyncCallback>} callback - callback rotation matrix. + * @returns {void | Promise>} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function transformRotationMatrix(inRotationVector: Array, coordinates: CoordinatesOptions, + callback: AsyncCallback>): void; + function transformRotationMatrix(inRotationVector: Array, coordinates: CoordinatesOptions): Promise>; + /** * convert a rotation vector to a normalized quaternion. * @@ -820,10 +1723,25 @@ declare namespace sensor { * @return Returns the normalized quaternion. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 + * @useinstead getQuaternion, {@code getQuaternion}. */ function createQuaternion(rotationVector: Array, callback: AsyncCallback>): void; function createQuaternion(rotationVector: Array): Promise>; + /** + * convert a rotation vector to a normalized quaternion. + * @param rotationVector Indicates the rotation vector. + * @param {AsyncCallback>} callback - callback a normalized quaternion. + * @returns {void | Promise>} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function getQuaternion(rotationVector: Array, callback: AsyncCallback>): void; + function getQuaternion(rotationVector: Array): Promise>; + /** * Computes the device's orientation based on the rotation matrix. * @@ -831,10 +1749,25 @@ declare namespace sensor { * @return Returns the array is the angle of rotation around the z, x, y axis. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 + * @useinstead getOrientation, {@code getOrientation}. */ function getDirection(rotationMatrix: Array, callback: AsyncCallback>): void; function getDirection(rotationMatrix: Array): Promise>; + /** + * Computes the device's orientation based on the rotation matrix. + * @param rotationMatrix Indicates the rotation matrix. + * @param {AsyncCallback>} callback - callback the angle of rotation around the z, x, y axis. + * @returns {void | Promise>} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function getOrientation(rotationMatrix: Array, callback: AsyncCallback>): void; + function getOrientation(rotationMatrix: Array): Promise>; + /** * Indicates the response of rotation matrix. * @syscap SystemCapability.Sensors.Sensor @@ -853,10 +1786,26 @@ declare namespace sensor { * @return Returns the rotation matrix, {@code RotationMatrixResponse}. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 + * @useinstead getRotationMatrix, {@code getRotationMatrix}. */ function createRotationMatrix(gravity: Array, geomagnetic: Array, callback: AsyncCallback): void; function createRotationMatrix(gravity: Array, geomagnetic: Array,): Promise; + /** + * Calculate rotation matrix based on gravity vector and geomagnetic vector. + * @param gravity Indicates the gravity vector. + * @param geomagnetic Indicates the geomagnetic vector. + * @param {AsyncCallback>} callback - callback rotation matrix and inclination matrix. + * @returns {void | Promise} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function getRotationMatrix(gravity: Array, geomagnetic: Array, callback: AsyncCallback): void; + function getRotationMatrix(gravity: Array, geomagnetic: Array,): Promise; + /** * Subscribe to the sensor's optional parameters. * @syscap SystemCapability.Sensors.Sensor @@ -870,6 +1819,8 @@ declare namespace sensor { * The type of number. * @syscap SystemCapability.Sensors.Sensor * @since 8 + * @deprecated since 9 + * @useinstead SensorId, {@code SensorId}. */ enum SensorType { SENSOR_TYPE_ID_ACCELEROMETER = 1, /**< Acceleration sensor */ @@ -882,18 +1833,7 @@ declare namespace sensor { SENSOR_TYPE_ID_HUMIDITY = 13, /**< Humidity sensor */ SENSOR_TYPE_ID_ORIENTATION = 256, /**< Orientation sensor */ SENSOR_TYPE_ID_GRAVITY = 257, /**< Gravity sensor */ - /** - * The type of number. - * @syscap SystemCapability.Sensors.Sensor - * @deprecated since 9 - * @useinstead SENSOR_TYPE_ID_LINEAR_ACCELEROMETER - */ SENSOR_TYPE_ID_LINEAR_ACCELERATION = 258, /**< Linear acceleration sensor */ - /** - * The type of number. - * @syscap SystemCapability.Sensors.Sensor - * @since 9 - */ SENSOR_TYPE_ID_LINEAR_ACCELEROMETER = 258, /**< Linear acceleration sensor */ SENSOR_TYPE_ID_ROTATION_VECTOR = 259, /**< Rotation vector sensor */ SENSOR_TYPE_ID_AMBIENT_TEMPERATURE = 260, /**< Ambient temperature sensor */ @@ -902,18 +1842,7 @@ declare namespace sensor { SENSOR_TYPE_ID_SIGNIFICANT_MOTION = 264, /**< Significant motion sensor */ SENSOR_TYPE_ID_PEDOMETER_DETECTION = 265, /**< Pedometer detection sensor */ SENSOR_TYPE_ID_PEDOMETER = 266, /**< Pedometer sensor */ - /** - * The type of number. - * @syscap SystemCapability.Sensors.Sensor - * @deprecated since 9 - * @useinstead SENSOR_TYPE_ID_HEART_BEAT_RATE - */ SENSOR_TYPE_ID_HEART_RATE = 278, /**< Heart rate sensor */ - /** - * The type of number. - * @syscap SystemCapability.Sensors.Sensor - * @since 9 - */ SENSOR_TYPE_ID_HEART_BEAT_RATE = 278, /**< Heart rate sensor */ SENSOR_TYPE_ID_WEAR_DETECTION = 280, /**< Wear detection sensor */ SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED = 281 /**< Uncalibrated acceleration sensor */ @@ -1056,7 +1985,7 @@ declare namespace sensor { * @since 8 */ interface HallResponse extends Response { - status: number; /**< Indicates hall status, event 0 indicates open, while 1 indicates close*/ + status: number; /**< Indicates hall status, 0 indicates open, and greater than 0 indicates suction */ } /** diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index e8f1bece16..04290e7031 100755 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -30,12 +30,104 @@ import { AsyncCallback } from './basic'; * @import import vibrator from '@ohos.vibrator' */ declare namespace vibrator { + /** + * The error code of vibration. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + enum ErrorCode { + /* Indicates input parameter range error.*/ + INPUT_PARAM_ERROR = 14600101, + /* Indicates connect vibrator service fail.*/ + CONNECT_SERVICE_FAIL = 14600102, + /* Indicates vibrate fail, does not support vibration or does not support vibration effects.*/ + VIBRATE_FAIL = 14600103, + /* Indicates that the stop failed, the vibration is not activated or the stop mode does not match.*/ + STOP_FAIL = 14600104 + } + + /** + * The use of vibration. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + type Usage = "unknown" | "alarm" | "ring" | "notification" | "communication" | + "touch" | "media" | "physicalFeedback" | "simulateReality"; + + /** + * The attribute of vibration. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + interface VibrateAttribute { + id?: number, /** Vibrator id, default is 0. */ + usage: Usage, /** The use of vibration. */ + } + + /** + * Specifies the duration of the vibration effect. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + interface VibrateTime { + type: "time", + duration: number /** The duration of the vibration, in ms */ + } + + /** + * Preset vibration type vibration effect. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + interface VibratePreset { + type: "preset"; + effectId: string, /** Preset type vibration */ + count: number /** The number of vibration repetitions */ + } + + /** + * Describes the effect of vibration. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + type VibrateEffect = VibrateTime | VibratePreset; + + /** + * Trigger vibrator vibration. + * @param {VibrateEffect} effect - Indicate vibrate effect, {@code VibrateEffect}. + * @param {VibrateAttribute} attribute: Indicate vibrate attribute, {@code VibrateAttribute}. + * @param {AsyncCallback} callback - callback. + * @returns {void | Promise} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * + * @permission ohos.permission.VIBRATE + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + function vibrate(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback): void; + function vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise; + + /** + * Stop the motor from vibrating. + * @param {VibratorStopMode} stopMode - Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}. + * @param {AsyncCallback} callback - callback. + * @returns {void | Promise} no callback return Promise otherwise return void. + * @throws {TypedError} Parameter check failed. + * + * @syscap SystemCapability.Sensors.MiscDevice + * @permission ohos.permission.VIBRATE + * @since 9 + */ + function stop(stopMode: VibratorStopMode): Promise; + function stop(stopMode: VibratorStopMode, callback: AsyncCallback): void; + /** * The trigger motor vibrates for a specified length of time. * @param duration Indicate the duration of the motor vibration. * @syscap SystemCapability.Sensors.MiscDevice * @permission ohos.permission.VIBRATE * @since 8 + * @deprecated since 9 */ function vibrate(duration: number, callback?: AsyncCallback): void; function vibrate(duration: number): Promise; @@ -45,6 +137,7 @@ declare namespace vibrator { * @param effectId Indicate the specified effect of the preset, {@code EffectId}. * @syscap SystemCapability.Sensors.MiscDevice * @permission ohos.permission.VIBRATE + * @deprecated since 9 * @since 8 */ function vibrate(effectId: EffectId): Promise; @@ -55,6 +148,7 @@ declare namespace vibrator { * @param stopMode Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}. * @syscap SystemCapability.Sensors.MiscDevice * @permission ohos.permission.VIBRATE + * @deprecated since 9 * @since 8 */ function stop(stopMode: VibratorStopMode): Promise; -- Gitee From a861053a4f42c878e698615ed1c9a76fbebab1eb Mon Sep 17 00:00:00 2001 From: h00514358 Date: Mon, 5 Sep 2022 11:37:23 +0800 Subject: [PATCH 2/2] add sensor js api Signed-off-by: h00514358 --- api/@ohos.sensor.d.ts | 164 ++++++++++++++++++++-------------------- api/@ohos.vibrator.d.ts | 14 +--- 2 files changed, 86 insertions(+), 92 deletions(-) diff --git a/api/@ohos.sensor.d.ts b/api/@ohos.sensor.d.ts index 93869b669b..5424955efb 100644 --- a/api/@ohos.sensor.d.ts +++ b/api/@ohos.sensor.d.ts @@ -28,14 +28,8 @@ declare namespace sensor { * @since 9 */ enum ErrorCode { - /* Indicates input parameter range error.*/ - INPUT_PARAM_ERROR = 14500101, - /* Indicates connect sensors service fail.*/ - CONNECT_SERVICE_FAIL = 14500102, - /* Indicates that the device does not support subscribe the sensor.*/ - SENSOR_NOT_EXIST = 14500103, - /* Indicates that unsubscribe sensor failed, you should subscribe first.*/ - UNSUBSCRIBE_FAIL = 14500104 + /* Indicates operation fail.*/ + OPERATION_FAIL = 14500101, } /** * The type of sensor. @@ -71,7 +65,7 @@ declare namespace sensor { * @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 {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor @@ -86,7 +80,7 @@ declare namespace sensor { * {@code SensorId.ACCELEROMETER_UNCALIBRATED}. * @param {Callback} callback - callback uncalibrated accelerometer data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor @@ -100,7 +94,7 @@ declare namespace sensor { * @param {SensorId.AMBIENT_LIGHT} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_LIGHT}. * @param {Callback} callback - callback ambient data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -112,7 +106,7 @@ declare namespace sensor { * @param {SensorId.AMBIENT_TEMPERATURE} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_TEMPERATURE}. * @param {Callback} callback - callback temperature data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -125,7 +119,7 @@ declare namespace sensor { * @param {SensorId.BAROMETER} type - Indicate the sensor type to listen for, {@code SensorId.BAROMETER}. * @param {Callback} callback - callback barometer data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -137,7 +131,7 @@ declare namespace sensor { * @param {SensorId.GRAVITY} type - Indicate the sensor type to listen for, {@code SensorId.GRAVITY}. * @param {Callback} callback - callback gravity data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -150,8 +144,9 @@ declare namespace sensor { * @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 {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * + * @permission ohos.permission.GYROSCOPE * @syscap SystemCapability.Sensors.Sensor * @since 9 */ @@ -163,8 +158,9 @@ declare namespace sensor { * @param {SensorId.GYROSCOPE_UNCALIBRATED} type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE_UNCALIBRATED}. * @param {Callback} callback - callback uncalibrated gyroscope data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * + * @permission ohos.permission.GYROSCOPE * @syscap SystemCapability.Sensors.Sensor * @since 9 */ @@ -176,7 +172,7 @@ declare namespace sensor { * @param {SensorId.HALL} type - Indicate the sensor type to listen for, {@code SensorId.HALL}. * @param {Callback} callback - callback uncalibrated gyroscope data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -188,7 +184,7 @@ declare namespace sensor { * @param {SensorId.HEART_RATE} type - Indicate the sensor type to listen for, {@code SensorId.HEART_RATE}. * @param {Callback} callback - callback heart rate data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.READ_HEALTH_DATA * @syscap SystemCapability.Sensors.Sensor @@ -202,7 +198,7 @@ declare namespace sensor { * @param {SensorId.HUMIDITY} type - Indicate the sensor type to listen for, {@code SensorId.HUMIDITY}. * @param {Callback} callback - callback humidity data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -215,7 +211,7 @@ declare namespace sensor { * @param {SensorId.LINEAR_ACCELERATION} type - Indicate the sensor type to listen for, {@code SensorId.LINEAR_ACCELERATION}. * @param {Callback} callback - callback linear acceleration data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor @@ -229,7 +225,7 @@ declare namespace sensor { * @param {SensorId.MAGNETIC_FIELD} type - Indicate the sensor type to listen for, {@code SensorId.MAGNETIC_FIELD}. * @param {Callback} callback - callback magnetic field data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -243,7 +239,7 @@ declare namespace sensor { * {@code SensorId.MAGNETIC_FIELD_UNCALIBRATED}. * @param {Callback} callback - callback uncalibrated magnetic field data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -256,7 +252,7 @@ declare namespace sensor { * @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 {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -269,7 +265,7 @@ declare namespace sensor { * @param {SensorId.PEDOMETER} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER}. * @param {Callback} callback - callback pedometer data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACTIVITY_MOTION * @syscap SystemCapability.Sensors.Sensor @@ -282,7 +278,7 @@ declare namespace sensor { * @param {SensorId.PEDOMETER_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER_DETECTION}. * @param {Callback} callback - callback pedometer detection data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACTIVITY_MOTION * @syscap SystemCapability.Sensors.Sensor @@ -296,7 +292,7 @@ declare namespace sensor { * @param {SensorId.PROXIMITY} type - Indicate the sensor type to listen for, {@code SensorId.PROXIMITY}. * @param {Callback} callback - callback proximity data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -308,7 +304,7 @@ declare namespace sensor { * @param {SensorId.ROTATION_VECTOR} type - Indicate the sensor type to listen for, {@code SensorId.ROTATION_VECTOR}. * @param {Callback} callback - callback rotation vector data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -321,7 +317,7 @@ declare namespace sensor { * @param {SensorId.SIGNIFICANT_MOTION} type - Indicate the sensor type to listen for, {@code SensorId.SIGNIFICANT_MOTION}. * @param {Callback} callback - callback significant motion data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -334,7 +330,7 @@ declare namespace sensor { * @param {SensorId.WEAR_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.WEAR_DETECTION}. * @param {Callback} callback - callback wear detection data. * @param {Options} options - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -346,7 +342,7 @@ declare namespace sensor { * Subscribe to accelerometer sensor data once. * @param {SensorId.ACCELEROMETER} type - Indicate the sensor type to listen for, {@code SensorId.ACCELEROMETER}. * @param {Callback} callback - callback accelerometer data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor @@ -359,7 +355,7 @@ declare namespace sensor { * @param {SensorId.ACCELEROMETER_UNCALIBRATED} type - Indicate the sensor type to listen for, * {@code SensorId.ACCELEROMETER_UNCALIBRATED}. * @param {Callback} callback - callback uncalibrated accelerometer data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor @@ -371,7 +367,7 @@ declare namespace sensor { * Subscribe to ambient light sensor data once. * @param {SensorId.AMBIENT_LIGHT} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_LIGHT}. * @param {Callback} callback - callback ambient data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -382,7 +378,7 @@ declare namespace sensor { * Subscribe to ambient temperature sensor data once. * @param {SensorId.AMBIENT_TEMPERATURE} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_TEMPERATURE}. * @param {Callback} callback - callback temperature data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -394,7 +390,7 @@ declare namespace sensor { * @param {SensorId.BAROMETER} type - Indicate the sensor type to listen for, {@code SensorId.BAROMETER}. * @param {Callback} callback - callback barometer data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -406,7 +402,7 @@ declare namespace sensor { * @param {SensorId.GRAVITY} type - Indicate the sensor type to listen for, {@code SensorId.GRAVITY}. * @param {Callback} callback - callback gravity data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -417,8 +413,9 @@ declare namespace sensor { * Subscribe to gyroscope sensor data once. * @param {SensorId.GYROSCOPE} type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE}. * @param {Callback} callback - callback gyroscope data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * + * @permission ohos.permission.GYROSCOPE * @syscap SystemCapability.Sensors.Sensor * @since 9 */ @@ -428,8 +425,9 @@ declare namespace sensor { * Subscribe to uncalibrated gyroscope sensor data once. * @param {SensorId.GYROSCOPE_UNCALIBRATED} type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE_UNCALIBRATED}. * @param {Callback} callback - callback uncalibrated gyroscope data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * + * @permission ohos.permission.GYROSCOPE * @syscap SystemCapability.Sensors.Sensor * @since 9 */ @@ -439,7 +437,7 @@ declare namespace sensor { * Subscribe to hall sensor data once. * @param {SensorId.HALL} type - Indicate the sensor type to listen for, {@code SensorId.HALL}. * @param {Callback} callback - callback uncalibrated gyroscope data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -450,7 +448,7 @@ declare namespace sensor { * Subscribe to heart rate sensor data once. * @param {SensorId.HEART_RATE} type - Indicate the sensor type to listen for, {@code SensorId.HEART_RATE}. * @param {Callback} callback - callback heart rate data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.READ_HEALTH_DATA * @syscap SystemCapability.Sensors.Sensor @@ -462,7 +460,7 @@ declare namespace sensor { * Subscribe to humidity sensor data once. * @param {SensorId.HUMIDITY} type - Indicate the sensor type to listen for, {@code SensorId.HUMIDITY}. * @param {Callback} callback - callback humidity data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -473,7 +471,7 @@ declare namespace sensor { * Subscribe to linear acceleration sensor data once. * @param {SensorId.LINEAR_ACCELERATION} type - Indicate the sensor type to listen for, {@code SensorId.LINEAR_ACCELERATION}. * @param {Callback} callback - callback linear acceleration data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor @@ -485,7 +483,7 @@ declare namespace sensor { * Subscribe to magnetic field sensor data once. * @param {SensorId.MAGNETIC_FIELD} type - Indicate the sensor type to listen for, {@code SensorId.MAGNETIC_FIELD}. * @param {Callback} callback - callback magnetic field data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -497,7 +495,7 @@ declare namespace sensor { * @param {SensorId.MAGNETIC_FIELD_UNCALIBRATED} type - Indicate the sensor type to listen for, * {@code SensorId.MAGNETIC_FIELD_UNCALIBRATED}. * @param {Callback} callback - callback uncalibrated magnetic field data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -508,7 +506,7 @@ declare namespace sensor { * Subscribe to orientation sensor data once. * @param {SensorId.ORIENTATION} type - Indicate the sensor type to listen for, {@code SensorId.ORIENTATION}. * @param {Callback} callback - callback orientation data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -519,7 +517,7 @@ declare namespace sensor { * Subscribe to pedometer sensor data once. * @param {SensorId.PEDOMETER} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER}. * @param {Callback} callback - callback pedometer data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACTIVITY_MOTION * @syscap SystemCapability.Sensors.Sensor @@ -531,7 +529,7 @@ declare namespace sensor { * Subscribe to pedometer detection sensor data once. * @param {SensorId.PEDOMETER_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER_DETECTION}. * @param {Callback} callback - callback pedometer detection data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACTIVITY_MOTION * @syscap SystemCapability.Sensors.Sensor @@ -543,7 +541,7 @@ declare namespace sensor { * Subscribe to proximity sensor data once. * @param {SensorId.PROXIMITY} type - Indicate the sensor type to listen for, {@code SensorId.PROXIMITY}. * @param {Callback} callback - callback proximity data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -554,7 +552,7 @@ declare namespace sensor { * Subscribe to rotation vector sensor data once. * @param {SensorId.ROTATION_VECTOR} type - Indicate the sensor type to listen for, {@code SensorId.ROTATION_VECTOR}. * @param {Callback} callback - callback rotation vector data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -566,7 +564,7 @@ declare namespace sensor { * Subscribe to significant motion sensor data once. * @param {SensorId.SIGNIFICANT_MOTION} type - Indicate the sensor type to listen for, {@code SensorId.SIGNIFICANT_MOTION}. * @param {Callback} callback - callback significant motion data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -577,7 +575,7 @@ declare namespace sensor { * Subscribe to wear detection sensor data once. * @param {SensorId.WEAR_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.WEAR_DETECTION}. * @param {Callback} callback - callback wear detection data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -587,7 +585,7 @@ declare namespace sensor { * Unsubscribe to accelerometer sensor data. * @param {SensorId.ACCELEROMETER} type - Indicate the sensor type to listen for, {@code SensorId.ACCELEROMETER}. * @param {Callback} callback - callback accelerometer data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor @@ -600,7 +598,7 @@ declare namespace sensor { * @param {SensorId.ACCELEROMETER_UNCALIBRATED} type - Indicate the sensor type to listen for, * {@code SensorId.ACCELEROMETER_UNCALIBRATED}. * @param {Callback} callback - callback uncalibrated accelerometer data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor @@ -612,7 +610,7 @@ declare namespace sensor { * Unsubscribe to ambient light sensor data. * @param {SensorId.AMBIENT_LIGHT} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_LIGHT}. * @param {Callback} callback - callback ambient data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -623,7 +621,7 @@ declare namespace sensor { * Unsubscribe to ambient temperature sensor data. * @param {SensorId.AMBIENT_TEMPERATURE} type - Indicate the sensor type to listen for, {@code SensorId.AMBIENT_TEMPERATURE}. * @param {Callback} callback - callback temperature data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -635,7 +633,7 @@ declare namespace sensor { * @param {SensorId.BAROMETER} type - Indicate the sensor type to listen for, {@code SensorId.BAROMETER}. * @param {Callback} callback - callback barometer data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -647,7 +645,7 @@ declare namespace sensor { * @param {SensorId.GRAVITY} type - Indicate the sensor type to listen for, {@code SensorId.GRAVITY}. * @param {Callback} callback - callback gravity data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -658,8 +656,9 @@ declare namespace sensor { * Unsubscribe to gyroscope sensor data. * @param {SensorId.GYROSCOPE} type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE}. * @param {Callback} callback - callback gyroscope data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * + * @permission ohos.permission.GYROSCOPE * @syscap SystemCapability.Sensors.Sensor * @since 9 */ @@ -669,8 +668,9 @@ declare namespace sensor { * Unsubscribe to uncalibrated gyroscope sensor data. * @param {SensorId.GYROSCOPE_UNCALIBRATED} type - Indicate the sensor type to listen for, {@code SensorId.GYROSCOPE_UNCALIBRATED}. * @param {Callback} callback - callback uncalibrated gyroscope data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * + * @permission ohos.permission.GYROSCOPE * @syscap SystemCapability.Sensors.Sensor * @since 9 */ @@ -680,7 +680,7 @@ declare namespace sensor { * Unsubscribe to hall sensor data. * @param {SensorId.HALL} type - Indicate the sensor type to listen for, {@code SensorId.HALL}. * @param {Callback} callback - callback uncalibrated gyroscope data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -691,7 +691,7 @@ declare namespace sensor { * Unsubscribe to heart rate sensor data. * @param {SensorId.HEART_RATE} type - Indicate the sensor type to listen for, {@code SensorId.HEART_RATE}. * @param {Callback} callback - callback heart rate data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.READ_HEALTH_DATA * @syscap SystemCapability.Sensors.Sensor @@ -703,7 +703,7 @@ declare namespace sensor { * Unsubscribe to humidity sensor data. * @param {SensorId.HUMIDITY} type - Indicate the sensor type to listen for, {@code SensorId.HUMIDITY}. * @param {Callback} callback - callback humidity data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -714,7 +714,7 @@ declare namespace sensor { * Unsubscribe to linear acceleration sensor data. * @param {SensorId.LINEAR_ACCELERATION} type - Indicate the sensor type to listen for, {@code SensorId.LINEAR_ACCELERATION}. * @param {Callback} callback - callback linear acceleration data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACCELEROMETER * @syscap SystemCapability.Sensors.Sensor @@ -726,7 +726,7 @@ declare namespace sensor { * Unsubscribe to magnetic field sensor data. * @param {SensorId.MAGNETIC_FIELD} type - Indicate the sensor type to listen for, {@code SensorId.MAGNETIC_FIELD}. * @param {Callback} callback - callback magnetic field data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -738,7 +738,7 @@ declare namespace sensor { * @param {SensorId.MAGNETIC_FIELD_UNCALIBRATED} type - Indicate the sensor type to listen for, * {@code SensorId.MAGNETIC_FIELD_UNCALIBRATED}. * @param {Callback} callback - callback uncalibrated magnetic field data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -749,7 +749,7 @@ declare namespace sensor { * 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 {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -760,7 +760,7 @@ declare namespace sensor { * Unsubscribe to pedometer sensor data. * @param {SensorId.PEDOMETER} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER}. * @param {Callback} callback - callback pedometer data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACTIVITY_MOTION * @syscap SystemCapability.Sensors.Sensor @@ -772,7 +772,7 @@ declare namespace sensor { * Unsubscribe to pedometer detection sensor data. * @param {SensorId.PEDOMETER_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.PEDOMETER_DETECTION}. * @param {Callback} callback - callback pedometer detection data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.ACTIVITY_MOTION * @syscap SystemCapability.Sensors.Sensor @@ -784,7 +784,7 @@ declare namespace sensor { * Unsubscribe to proximity sensor data. * @param {SensorId.PROXIMITY} type - Indicate the sensor type to listen for, {@code SensorId.PROXIMITY}. * @param {Callback} callback - callback proximity data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -795,7 +795,7 @@ declare namespace sensor { * Unsubscribe to rotation vector sensor data. * @param {SensorId.ROTATION_VECTOR} type - Indicate the sensor type to listen for, {@code SensorId.ROTATION_VECTOR}. * @param {Callback} callback - callback rotation vector data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -807,7 +807,7 @@ declare namespace sensor { * Unsubscribe to significant motion sensor data. * @param {SensorId.SIGNIFICANT_MOTION} type - Indicate the sensor type to listen for, {@code SensorId.SIGNIFICANT_MOTION}. * @param {Callback} callback - callback significant motion data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -818,7 +818,7 @@ declare namespace sensor { * Unsubscribe to wear detection sensor data. * @param {SensorId.WEAR_DETECTION} type - Indicate the sensor type to listen for, {@code SensorId.WEAR_DETECTION}. * @param {Callback} callback - callback wear detection data. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -1482,7 +1482,7 @@ declare namespace sensor { * @param type Indicate the sensor type, {@code SensorId}. * @param {AsyncCallback} callback - callback sensor info. * @returns {void | Promise} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -1495,7 +1495,7 @@ declare namespace sensor { * @param type Indicate the sensor type, {@code SensorId}. * @param {AsyncCallback>} callback - callback sensor list. * @returns {void | Promise>} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -1551,7 +1551,7 @@ declare namespace sensor { * since the Unix epoch. * @param {AsyncCallback} callback - callback geomagnetic field. * @returns {void | Promise} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -1579,7 +1579,7 @@ declare namespace sensor { * @param currentPressure Indicates the atmospheric pressure measured by the barometer, in hPa. * @param {AsyncCallback} callback - callback device altitude. * @returns {void | Promise} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -1605,7 +1605,7 @@ declare namespace sensor { * @param inclinationMatrix Indicates the inclination matrix. * @param {AsyncCallback} callback - callback inclination in radians. * @returns {void | Promise} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -1634,7 +1634,7 @@ declare namespace sensor { * @param preRotationMatrix Indicates the current rotation matrix. * @param {AsyncCallback>} callback - callback angle variation. * @returns {void | Promise>} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -1661,7 +1661,7 @@ declare namespace sensor { * @param rotationVector Indicates the rotation vector. * @param {AsyncCallback>} callback - callback rotation matrix. * @returns {void | Promise>} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -1707,7 +1707,7 @@ declare namespace sensor { * @param coordinates Indicates coordinate system guidance, {@code CoordinatesOptions}. * @param {AsyncCallback>} callback - callback rotation matrix. * @returns {void | Promise>} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -1734,7 +1734,7 @@ declare namespace sensor { * @param rotationVector Indicates the rotation vector. * @param {AsyncCallback>} callback - callback a normalized quaternion. * @returns {void | Promise>} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -1760,7 +1760,7 @@ declare namespace sensor { * @param rotationMatrix Indicates the rotation matrix. * @param {AsyncCallback>} callback - callback the angle of rotation around the z, x, y axis. * @returns {void | Promise>} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 @@ -1798,7 +1798,7 @@ declare namespace sensor { * @param geomagnetic Indicates the geomagnetic vector. * @param {AsyncCallback>} callback - callback rotation matrix and inclination matrix. * @returns {void | Promise} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.Sensor * @since 9 diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index 04290e7031..a4855bed63 100755 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -36,14 +36,8 @@ declare namespace vibrator { * @since 9 */ enum ErrorCode { - /* Indicates input parameter range error.*/ - INPUT_PARAM_ERROR = 14600101, - /* Indicates connect vibrator service fail.*/ - CONNECT_SERVICE_FAIL = 14600102, - /* Indicates vibrate fail, does not support vibration or does not support vibration effects.*/ - VIBRATE_FAIL = 14600103, - /* Indicates that the stop failed, the vibration is not activated or the stop mode does not match.*/ - STOP_FAIL = 14600104 + /* Indicates operation fail.*/ + OPERATION_FAIL = 14500101, } /** @@ -98,7 +92,7 @@ declare namespace vibrator { * @param {VibrateAttribute} attribute: Indicate vibrate attribute, {@code VibrateAttribute}. * @param {AsyncCallback} callback - callback. * @returns {void | Promise} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @permission ohos.permission.VIBRATE * @syscap SystemCapability.Sensors.MiscDevice @@ -112,7 +106,7 @@ declare namespace vibrator { * @param {VibratorStopMode} stopMode - Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}. * @param {AsyncCallback} callback - callback. * @returns {void | Promise} no callback return Promise otherwise return void. - * @throws {TypedError} Parameter check failed. + * @throws {BusinessError} Parameter check failed. * * @syscap SystemCapability.Sensors.MiscDevice * @permission ohos.permission.VIBRATE -- Gitee