diff --git a/api/@ohos.sensor.d.ts b/api/@ohos.sensor.d.ts old mode 100755 new mode 100644 index 231c236f6b769c3d5c54007416f3c3e0297858d7..5f2c8cd91d9879edec08b035091200370c7b1112 --- a/api/@ohos.sensor.d.ts +++ b/api/@ohos.sensor.d.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { AsyncCallback } from './basic'; +import { AsyncCallback, Callback } from "./basic"; /** * This module provides the capability to subscribe to sensor data. @@ -32,7 +32,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback, options?: Options): void; /** @@ -43,7 +43,7 @@ declare namespace sensor { * @syscap SystemCapability.Sensors.Sensor * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback: Callback, options?: Options): void; /** @@ -54,7 +54,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback, options?: Options): void; /** @@ -65,7 +65,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback: Callback, options?: Options): void; /** @@ -76,7 +76,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback, options?: Options): void; /** @@ -87,7 +87,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback, options?: Options): void; /** @@ -98,7 +98,7 @@ declare namespace sensor { * @permission ohos.permission.GRYOSCOPE * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback, options?: Options): void; /** @@ -109,7 +109,7 @@ declare namespace sensor { * @permission ohos.permission.GRYOSCOPE * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback: Callback, options?: Options): void; /** @@ -120,7 +120,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback, options?: Options): void; /** @@ -131,7 +131,7 @@ declare namespace sensor { * @permission ohos.permission.HEALTH_DATA * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback, options?: Options): void; /** @@ -142,7 +142,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback, options?: Options): void; /** @@ -153,7 +153,7 @@ declare namespace sensor { * @permission ohos.permission.ACCELEROMETER * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback: Callback, options?: Options): void; /** @@ -164,7 +164,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback, options?: Options): void; /** @@ -175,7 +175,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback: Callback, options?: Options): void; /** @@ -186,7 +186,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback, options?: Options): void; /** @@ -197,7 +197,7 @@ declare namespace sensor { * @permission ohos.permission.ACTIVITY_MOTION * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback, options?: Options): void; /** @@ -208,7 +208,7 @@ declare namespace sensor { * @permission ohos.permission.ACTIVITY_MOTION * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback, options?: Options): void; /** @@ -219,7 +219,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback, options?: Options): void; /** @@ -230,7 +230,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback, options?: Options): void; /** @@ -241,7 +241,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback, options?: Options): void; /** @@ -252,7 +252,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: AsyncCallback, + function on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback, options?: Options): void; /** @@ -262,7 +262,7 @@ declare namespace sensor { * @permission ohos.permission.ACCELEROMETER * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback): void; /** * Subscribe to sensor data once. @@ -271,7 +271,7 @@ declare namespace sensor { * @permission ohos.permission.ACCELEROMETER * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback: Callback): void; /** * Subscribe to sensor data once. @@ -280,7 +280,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback): void; /** * Subscribe to sensor data once. @@ -289,7 +289,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback: Callback): void; /** * Subscribe to sensor data once. @@ -298,7 +298,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback): void; /** * Subscribe to sensor data once. @@ -307,7 +307,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback): void; /** * Subscribe to sensor data once. @@ -316,7 +316,7 @@ declare namespace sensor { * @permission ohos.permission.GYROSCOPE * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback): void; /** * Subscribe to sensor data once. @@ -325,7 +325,7 @@ declare namespace sensor { * @permission ohos.permission.GYROSCOPE * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback: Callback): void; /** * Subscribe to sensor data once. @@ -334,7 +334,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback): void; /** * Subscribe to sensor data once. @@ -343,7 +343,7 @@ declare namespace sensor { * @permission ohos.permission.HEART_RATE * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback): void; /** * Subscribe to sensor data once. @@ -352,7 +352,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback): void; /** * Subscribe to sensor data once. @@ -361,7 +361,7 @@ declare namespace sensor { * @permission ohos.permission.ACCELERATION * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback: Callback): void; /** * Subscribe to sensor data once. @@ -370,7 +370,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback): void; /** * Subscribe to sensor data once. @@ -379,7 +379,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback: Callback): void; /** * Subscribe to sensor data once. @@ -388,7 +388,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback): void; /** * Subscribe to sensor data once. @@ -397,7 +397,7 @@ declare namespace sensor { * @permission ohos.permission.ACTIVITY_MOTION * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback): void; /** * Subscribe to sensor data once. @@ -406,7 +406,7 @@ declare namespace sensor { * @permission ohos.permission.ACTIVITY_MOTION * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback): void; /** * Subscribe to sensor data once. @@ -415,7 +415,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback): void; /** * Subscribe to sensor data once. @@ -424,7 +424,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback): void; /** * Subscribe to sensor data once. @@ -433,7 +433,7 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback): void; /** * Subscribe to sensor data once. @@ -442,16 +442,197 @@ declare namespace sensor { * @permission N/A * @since 8 */ - function once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: AsyncCallback): void; + function once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback): void; /** - * Unsubscribe to sensor data once. - * @param type Indicate the sensor type to listen for, {@code SensorType}. + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_ACCELEROMETER}. + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED}. + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, + callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT}. + * @syscap SystemCapability.Sensors.Sensor + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE}. + * @syscap SystemCapability.Sensors.Sensor + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_BAROMETER}. + * @syscap SystemCapability.Sensors.Sensor + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_GRAVITY}. + * @syscap SystemCapability.Sensors.Sensor + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_GYROSCOPE}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GRYOSCOPE + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GRYOSCOPE + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_HALL}. + * @syscap SystemCapability.Sensors.Sensor + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_HEART_RATE}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.HEALTH_DATA + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_HEART_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 + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 8 + */ + 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_MAGNETIC_FIELD}. + * @syscap SystemCapability.Sensors.Sensor + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED}. + * @syscap SystemCapability.Sensors.Sensor + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_ORIENTATION}. + * @syscap SystemCapability.Sensors.Sensor + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_PEDOMETER}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_PROXIMITY}. + * @syscap SystemCapability.Sensors.Sensor + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR}. + * @syscap SystemCapability.Sensors.Sensor + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION}. + * @syscap SystemCapability.Sensors.Sensor + * @permission N/A + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback): void; + + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_WEAR_DETECTION}. * @syscap SystemCapability.Sensors.Sensor * @permission N/A * @since 8 */ - function off(type: SensorType, callback: AsyncCallback): void; + function off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback): void; /** * Indicates geographic location. @@ -713,9 +894,9 @@ declare namespace sensor { * @since 8 */ interface OrientationResponse extends Response { - x: number; /**< Orientation x-axis component */ - y: number; /**< Orientation y-axis component */ - z: number; /**< Orientation z-axis component */ + alpha: number; /**< The device rotates at an angle around the Z axis */ + beta: number; /**< The device rotates at an angle around the X axis */ + gamma: number; /**< The device rotates at an angle around the Y axis */ } /** diff --git a/api/@system.sensor.d.ts b/api/@system.sensor.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5d7ecca4b7ecfa2bf648623cecc2da6814ab777 --- /dev/null +++ b/api/@system.sensor.d.ts @@ -0,0 +1,665 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.ACCELEROMETER + * @since 3 + * @deprecated since 8 + */ +export interface AccelerometerResponse { + /** + * X-coordinate + * @since 3 + */ + x: number; + + /** + * Y-coordinate + * @since 3 + */ + y: number; + + /** + * Z-coordinate + * @since 3 + */ + z: number; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.ACCELEROMETER + * @since 3 + * @deprecated since 8 + */ +export interface subscribeAccelerometerOptions { + /** + * Execution frequency of the callback function for listening to acceleration sensor data. + * Available values are as follows: + * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. + * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. + * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. + * The default value is normal. + * @since 3 + */ + interval: string; + + /** + * Called when acceleration sensor data changes. + * @since 3 + */ + success: (data: AccelerometerResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface CompassResponse { + /** + * Direction of the device (in degrees). + * @since 3 + */ + direction: number; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeCompassOptions { + /** + * Called when compass sensor data changes. + * @since 3 + */ + success: (data: CompassResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface ProximityResponse { + /** + * Distance between a visible object and the device screen + * @since 3 + */ + distance: number; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeProximityOptions { + /** + * Called when distance sensor data changes. + * @since 3 + */ + success: (data: ProximityResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface LightResponse { + /** + * Light intensity, in lux. + * @since 3 + */ + intensity: number; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeLightOptions { + /** + * Called when ambient light sensor data changes. + * @since 3 + */ + success: (data: LightResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.ACTIVITY_MOTION + * @since 3 + * @deprecated since 8 + */ +export interface StepCounterResponse { + /** + * Number of steps counted. + * Each time the device restarts, the value is recalculated from 0 in phone, tablet. + * @since 3 + */ + steps: number; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.ACTIVITY_MOTION + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeStepCounterOptions { + /** + * Called when step counter sensor data changes. + * @since 3 + */ + success: (data: StepCounterResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface BarometerResponse { + /** + * Pressure, in pascal. + * @since 3 + */ + pressure: number; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeBarometerOptions { + /** + * Called when the barometer sensor data changes. + * @since 3 + */ + success: (data: BarometerResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.READ_HEALTH_DATA + * @since 3 + * @deprecated since 8 + */ +export interface HeartRateResponse { + /** + * Heart rate. + * 255 indicates an invalid value in lite wearable. + * @since 3 + */ + heartRate: number; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.READ_HEALTH_DATA + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeHeartRateOptions { + /** + * Called when the heart rate sensor data changes. + * @since 3 + */ + success: (data: HeartRateResponse) => void; + + /** + * Called when the listening fails + * @since 3 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface OnBodyStateResponse { + /** + * Whether the sensor is worn. + * @since 3 + */ + value: boolean; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeOnBodyStateOptions { + /** + * Called when the wearing status changes. + * @since 3 + */ + success: (data: OnBodyStateResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface GetOnBodyStateOptions { + /** + * Called when the sensor wearing state is obtained + * @since 3 + */ + success: (data: OnBodyStateResponse) => void; + + /** + * Called when the sensor wearing state fails to be obtained + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed + * @since 3 + */ + complete?: () => void; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 6 + * @deprecated since 8 + */ +export interface DeviceOrientationResponse { + /** + * alpha + * @since 6 + */ + alpha: number; + + /** + * beta + * @since 6 + */ + beta: number; + + /** + * gamma + * @since 6 + */ + gamma: number; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 6 + * @deprecated since 8 + */ +export interface SubscribeDeviceOrientationOptions { + /** + * Execution frequency of the callback function for listening to device orientation sensor data. + * Available values are as follows: + * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. + * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. + * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. + * The default value is normal. + * @since 6 + */ + interval: string; + + /** + * Called when device orientation sensor data changes. + * @since 6 + */ + success: (data: DeviceOrientationResponse) => void; + + /** + * Called when the listening fails. + * @since 6 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.GYROSCOPE + * @since 6 + * @deprecated since 8 + */ +export interface GyroscopeResponse { + /** + * X-coordinate + * @since 6 + */ + x: number; + + /** + * Y-coordinate + * @since 6 + */ + y: number; + + /** + * Z-coordinate + * @since 6 + */ + z: number; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.GYROSCOPE + * @since 6 + * @deprecated since 8 + */ +export interface SubscribeGyroscopeOptions { + /** + * Execution frequency of the callback function for listening to gyroscope sensor data. + * Available values are as follows: + * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. + * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. + * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. + * The default value is normal. + * @since 6 + */ + interval: string; + + /** + * Called when gyroscope sensor data changes. + * @since 6 + */ + success: (data: GyroscopeResponse) => void; + + /** + * Called when the listening fails. + * @since 6 + */ + fail?: (data: string, code: number) => void; +} + +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 6 + * @deprecated since 8 + */ +export default class Sensor { + /** + * Listens to acceleration sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 3 + * @deprecated since 8 + */ + static subscribeAccelerometer(options: subscribeAccelerometerOptions): void; + + /** + * Cancels listening to acceleration sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 3 + * @deprecated since 8 + */ + static unsubscribeAccelerometer(): void; + + /** + * Listens to compass sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static subscribeCompass(options: SubscribeCompassOptions): void; + + /** + * Cancels listening to compass sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static unsubscribeCompass(): void; + + /** + * Listens to distance sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static subscribeProximity(options: SubscribeProximityOptions): void; + + /** + * Cancels listening to distance sensor data. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static unsubscribeProximity(): void; + + /** + * Listens to ambient light sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static subscribeLight(options: SubscribeLightOptions): void; + + /** + * Cancels listening to ambient light sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static unsubscribeLight(): void; + + /** + * Listens to step counter sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 3 + * @deprecated since 8 + */ + static subscribeStepCounter(options: SubscribeStepCounterOptions): void; + + /** + * Cancels listening to step counter sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 3 + * @deprecated since 8 + */ + static unsubscribeStepCounter(): void; + + /** + * Listens to barometer sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static subscribeBarometer(options: SubscribeBarometerOptions): void; + + /** + * Cancels listening to barometer sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static unsubscribeBarometer(): void; + + /** + * Listens to changes of heart rate sensor data. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.READ_HEALTH_DATA + * @since 3 + * @deprecated since 8 + */ + static subscribeHeartRate(options: SubscribeHeartRateOptions): void; + + /** + * Cancels listening to heart rate sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.READ_HEALTH_DATA + * @since 3 + * @deprecated since 8 + */ + static unsubscribeHeartRate(): void; + + /** + * Listens to whether a sensor is worn. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static subscribeOnBodyState(options: SubscribeOnBodyStateOptions): void; + + /** + * Cancels listening to whether the sensor is worn. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static unsubscribeOnBodyState(): void; + + /** + * Obtains the sensor wearing state. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static getOnBodyState(options: GetOnBodyStateOptions): void; + + /** + * Listens to device orientation sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 6 + * @deprecated since 8 + */ + static subscribeDeviceOrientation(options: SubscribeDeviceOrientationOptions): void; + + /** + * Cancels listening to device orientation sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @since 6 + * @deprecated since 8 + */ + static unsubscribeDeviceOrientation(): void; + + /** + * Listens to gyroscope sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GYROSCOPE + * @since 6 + * @deprecated since 8 + */ + static subscribeGyroscope(options: SubscribeGyroscopeOptions): void; + + /** + * Cancels listening to gyroscope sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GYROSCOPE + * @since 6 + * @deprecated since 8 + */ + static unsubscribeGyroscope(): void; +} diff --git a/api/@system.vibrator.d.ts b/api/@system.vibrator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8fd9d1be2962baa1b34bfa92fa54e26cbda0f38 --- /dev/null +++ b/api/@system.vibrator.d.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @syscap SystemCapability.Sensors.MiscDevice + * @import import vibrator from '@system.vibrator'; + * @permission ohos.permission.VIBRATE + * @since 3 + * @deprecated since 8 + */ +export interface VibrateOptions { + /** + * Vibration mode. The value long indicates long vibration, and short indicates short vibration. + * The default value is long. + * @since 3 + */ + mode?: "long" | "short"; + + /** + * Called when success to trigger vibration. + * @since 3 + */ + success: () => void; + + /** + * Called when fail to trigger vibration. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} + +/** + * @syscap SystemCapability.Sensors.MiscDevice + * @import import vibrator from '@system.vibrator'; + * @permission ohos.permission.VIBRATE + * @since 3 + * @deprecated since 8 + */ +export default class Vibrator { + /** + * Triggers vibration. + * @param options Options. + * @permission ohos.permission.VIBRATE + * @since 3 + * @deprecated since 8 + */ + static vibrate(options?: VibrateOptions): void; +}