From c4e1c6fde0710ef64c7824879711a055de52b9eb Mon Sep 17 00:00:00 2001 From: limabiao Date: Fri, 6 Jun 2025 17:35:26 +0800 Subject: [PATCH] =?UTF-8?q?sensor=20arkTs1.2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limabiao Change-Id: I1cec2dbd10a0fcc8ce72b5bc09afb84b9e52a2dd --- api/@ohos.sensor.d.ets | 191 ----------------------------------------- api/@ohos.sensor.d.ts | 75 ++++++++++++---- 2 files changed, 59 insertions(+), 207 deletions(-) delete mode 100644 api/@ohos.sensor.d.ets diff --git a/api/@ohos.sensor.d.ets b/api/@ohos.sensor.d.ets deleted file mode 100644 index 0963965dcf..0000000000 --- a/api/@ohos.sensor.d.ets +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2025 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. - */ - -/** - * @file - * @kit SensorServiceKit - */ - -import { AsyncCallback, Callback } from './@ohos.base'; - -/** - * This module provides the capability to subscribe to sensor data. - * @namespace sensor - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ -declare namespace sensor { - /** - * Subscribe to orientation sensor data. - * @param { SensorId.ORIENTATION } type - Indicate the sensor type to listen for, {@code SensorId.ORIENTATION}. - * @param { Callback } callback - callback orientation data. - * @param { Options } [options] - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - *
2. Incorrect parameter types; 3. Parameter verification failed. - * @throws { BusinessError } 14500101 - Service exception. - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - function on(type: 'ORIENTATION', callback: Callback, - options?: Options): 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 { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - *
2. Incorrect parameter types; 3. Parameter verification failed. - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - function off(type: 'ORIENTATION', callback?: Callback): void; - - /** - * Subscribe to the sensor's optional parameters. - * @typedef Options - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - interface Options { - /** - * Sensor event reporting event interval. - * @type { ?(number | SensorFrequency) } - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - interval?: number | SensorFrequency; - } - - /** - * The sensor reporting frequency is divided into three modes. - * @typedef {'game' | 'ui' | 'normal'} - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - type SensorFrequency = 'game' | 'ui' | 'normal'; - - /** - * Enumerates the accuracy levels of data reported by a sensor. - * @enum { number } - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - enum SensorAccuracy { - /** - * The sensor data is unreliable. It is possible that the sensor does not contact with the device to measure. - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - ACCURACY_UNRELIABLE = 0, - - /** - * The sensor data is at a low accuracy level. The data must be calibrated based on the environment before being used. - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - ACCURACY_LOW = 1, - - /** - * The sensor data is at a medium accuracy level. You are advised to calibrate the data based on the environment - *
before using it. - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - ACCURACY_MEDIUM = 2, - - /** - * The sensor data is at a high accuracy level. The data can be used directly. - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - ACCURACY_HIGH = 3 - } - - /** - * The basic data structure of the sensor event. - * @typedef Response - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - interface Response { - /** - * The timestamp of the reported sensor data. - * @type { number } - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - timestamp: number; - - /** - * The accuracy levels of data reported by a sensor. - * @type { SensorAccuracy } - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - accuracy: SensorAccuracy; - } - - /** - * Orientation sensor event data. - * @typedef OrientationResponse - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - interface OrientationResponse extends Response { - /** - * The device rotates at an angle around the Z axis. - * @type { number } - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - alpha: number; - - /** - * The device rotates at an angle around the X axis. - * @type { number } - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - beta: number; - - /** - * The device rotates at an angle around the Y axis. - * @type { number } - * @syscap SystemCapability.Sensors.Sensor - * @atomicservice - * @since 20 - */ - gamma: number; - } -} - -export default sensor; \ No newline at end of file diff --git a/api/@ohos.sensor.d.ts b/api/@ohos.sensor.d.ts index 6587cae21a..0c2593304e 100644 --- a/api/@ohos.sensor.d.ts +++ b/api/@ohos.sensor.d.ts @@ -31,7 +31,8 @@ import { AsyncCallback, Callback } from './@ohos.base'; * @namespace sensor * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ declare namespace sensor { /** @@ -544,6 +545,21 @@ declare namespace sensor { function on(type: SensorId.ORIENTATION, callback: Callback, options?: Options): void; + /** + * Subscribe to orientation sensor data. + * @param { 'ORIENTATION' } type - Indicate the sensor type to listen for, {@code SensorId.ORIENTATION}. + * @param { Callback } callback - callback orientation data. + * @param { Options } [options] - Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 14500101 - Service exception. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 20 + */ + function on(type: 'ORIENTATION', callback: Callback, + options?: Options): void; + /** * Subscribe to pedometer sensor data. * @permission ohos.permission.ACTIVITY_MOTION @@ -1159,6 +1175,18 @@ declare namespace sensor { */ function off(type: SensorId.ORIENTATION, callback?: Callback): void; + /** + * Unsubscribe to orientation sensor data. + * @param { 'ORIENTATION' } type - Indicate the sensor type to listen for, {@code SensorId.ORIENTATION}. + * @param { Callback } callback - callback orientation data. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @syscap SystemCapability.Sensors.Sensor + * @atomicservice + * @since 20 + */ + function off(type: 'ORIENTATION', callback?: Callback): void; + /** * Unsubscribe to pedometer sensor data. * @permission ohos.permission.ACTIVITY_MOTION @@ -2824,7 +2852,8 @@ declare namespace sensor { * @typedef Options * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ interface Options { /** @@ -2838,7 +2867,8 @@ declare namespace sensor { * @type { ?(number | SensorFrequency) } * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ interval?: number | SensorFrequency; } @@ -2848,7 +2878,8 @@ declare namespace sensor { * @typedef {'game' | 'ui' | 'normal'} * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ type SensorFrequency = 'game' | 'ui' | 'normal'; @@ -3035,14 +3066,16 @@ declare namespace sensor { * @enum { number } * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ enum SensorAccuracy { /** * The sensor data is unreliable. It is possible that the sensor does not contact with the device to measure. * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ ACCURACY_UNRELIABLE = 0, @@ -3050,7 +3083,8 @@ declare namespace sensor { * The sensor data is at a low accuracy level. The data must be calibrated based on the environment before being used. * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ ACCURACY_LOW = 1, @@ -3058,7 +3092,8 @@ declare namespace sensor { * The sensor data is at a medium accuracy level. You are advised to calibrate the data based on the environment before using it. * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ ACCURACY_MEDIUM = 2, @@ -3066,7 +3101,8 @@ declare namespace sensor { * The sensor data is at a high accuracy level. The data can be used directly. * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ ACCURACY_HIGH = 3 } @@ -3082,7 +3118,8 @@ declare namespace sensor { * @typedef Response * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ interface Response { /** @@ -3096,7 +3133,8 @@ declare namespace sensor { * @type { number } * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ timestamp: number; @@ -3105,7 +3143,8 @@ declare namespace sensor { * @type { SensorAccuracy } * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ accuracy: SensorAccuracy; } @@ -3304,7 +3343,8 @@ declare namespace sensor { * @typedef OrientationResponse * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ interface OrientationResponse extends Response { /** @@ -3318,7 +3358,8 @@ declare namespace sensor { * @type { number } * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ alpha: number; @@ -3333,7 +3374,8 @@ declare namespace sensor { * @type { number } * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ beta: number; @@ -3348,7 +3390,8 @@ declare namespace sensor { * @type { number } * @syscap SystemCapability.Sensors.Sensor * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ gamma: number; } -- Gitee