From e1f809d32c48600e18615ced99812f4fe8e78bf7 Mon Sep 17 00:00:00 2001 From: hero100 Date: Tue, 1 Apr 2025 14:52:16 +0800 Subject: [PATCH 01/11] miscdevice interface update Signed-off-by: hero100 --- api/@ohos.vibrator.d.ts | 264 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 263 insertions(+), 1 deletion(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index 8d08f4fea8..328a0bd02f 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -18,7 +18,7 @@ * @kit SensorServiceKit */ -import { AsyncCallback } from './@ohos.base'; +import { AsyncCallback, Callback } from './@ohos.base'; /** * This module provides the capability to control motor vibration. @@ -328,6 +328,258 @@ declare namespace vibrator { EFFECT_CLOCK_TIMER = 'haptic.clock.timer' } + /** + * Stop any type of vibration. + * + * @permission ohos.permission.VIBRATE + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 14600101 - Device operation failed. + * @syscap SystemCapability.Sensors.MiscDevice + * @atomicservice + * @since 18 + */ + function stopVibrationSync(param?: VibratorParam): void; + + /** + * Stop any type of vibration. + * + * @permission ohos.permission.VIBRATE + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. + * @returns { Promise } Promise used to return the result. + * @throws { BusinessError } 201 - Permission denied. + * @syscap SystemCapability.Sensors.MiscDevice + * @atomicservice + * @since 18 + */ + function stopVibration(param?: VibratorParam): Promise; + + /** + * Stop any type of vibration. + * + * @permission ohos.permission.VIBRATE + * @param { AsyncCallback } callback - The callback of stopVibration. + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. + * @throws { BusinessError } 201 - Permission denied. + * @syscap SystemCapability.Sensors.MiscDevice + * @atomicservice + * @since 18 + */ + function stopVibration(callback: AsyncCallback, param?: VibratorParam): void; + + /** + * Retrieve the list of vibrator IDs. + * + * @param { AsyncCallback } callback - The callback function for retrieving vibrator ID list. + * @param { VibratorParam } Param - The parameters for the vibrator. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 14600101 - Device operation failed. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + function GetVibratorList(callback: AsyncCallback>, Param?: VibratorParam): void; + + /** + * Retrieve the list of vibrator IDs. + * + * @param { VibratorParam } Param - The parameters for the vibrator. + * @returns { Array } Returns a list of vibrator IDs. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 14600101 - Device operation failed. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + function GetVibratorListSync(Param?: VibratorParam): Array; + + /** + * Retrieve effect information by device ID. + * + * @param { string } effectType - The effect type to retrieve. + * @param { AsyncCallback } callback - The callback function for retrieving effect information. + * @param { VibratorParam } Param - The parameters for the vibrator. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 14600101 - Device operation failed. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + function isSupportEffectInfo(effectType: string, callback: AsyncCallback, Param?: VibratorParam): void; + + /** + * Retrieve effect information by device ID. + * + * @param { string } effectType - Output parameter to store the effect type. + * @param { VibratorParam } Param - The parameters for the vibrator. + * @returns { EffectInfo } Returns information about the specified effect. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 14600101 - Device operation failed. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + function isSupportEffectInfoSync(effectType: string, Param?: VibratorParam): EffectInfo; + + /** + * Registers a callback function to be called when a vibrator plung event occurs. + * + * @param { PlugEventType.VIBRATOR_PLUGIN } type - The event type corresponding to the vibrator plugin. + * @param { Callback } callback - The callback function to be executed when the event is triggered. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Callback registration failed. Possible causes: 1. Callback function is not a valid function; + *
2. Insufficient permissions to register the callback. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + function on(type: PlugEventType.VIBRATOR_PLUGIN, callback: Callback): void; + + /** + * Deregisters a callback function that listens for the vibrator unplung event. + * + * @param { PlugEventType.VIBRATOR_UNPLUG } type - The event type corresponding to the vibrator unplug. + * @param { Callback } callback - The callback function to be removed from the event listener. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Callback deregistration failed. Possible causes: 1. Callback function not previously registered; + *
2. Insufficient permissions to deregister the callback. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + function off(type: PlugEventType.VIBRATOR_UNPLUG, callback: Callback): void; + + /** + * Interface representing the information of a vibrator device. + * + * @interface + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + * @property { number } deviceId - Unique identifier for the device that contains one or multiple vibrators. + * @property { boolean } VibratorDeviceState - Indicates the plug state of the device; true if plugged in, false if unplugged. + */ + interface VibratorDeviceInfo { + /** + * Unique identifier for the device that contains one or multiple vibrators. + * + * @type { number } + * @description A numeric value that serves as the unique identifier for the device. + * @since 18 + */ + deviceId: number; + + /** + * Indicates the plug state of the device. + * + * @type { boolean } + * @default false + * @description true if the device is plugged in; false if unplugged. + * @since 18 + */ + VibratorDeviceState: boolean; + } + + /** + * Enumeration representing various event types for vibrator operations. + * + * @enum { number } + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + enum PlugEventType { + /** + * Event triggered when the vibrator is plugged in. + * + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + VIBRATOR_PLUGIN = 1, + + /** + * Event triggered when the vibrator is unplugged. + * + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + VIBRATOR_UNPLUG = 0, + } + + /** + * @brief Represents the information about a vibrator device in the system. + * + * @interface VibratorInfo + * @since + */ + interface VibratorInfo { + /** + * Unique identifier for the device that contains one or multiple vibrators. + * + * @type { number } + */ + deviceId: number; + + /** + * Unique identifier for the vibrator itself within the device. + * + * @type { number } + */ + vibratorId: number; + + /** + * Name of the device. + * + * @type { string } + */ + deviceName: string; + + /** + * Indicates if the vibrator device support HD haptic. + * + * @type { boolean } + */ + isSupportHdHaptic: boolean; + } + + /** + * @brief Represents the parameters for querying vibrator information. + * + * @interface VibratorParam + * @since 18 + */ + interface VibratorParam { + /** + * Unique identifier for the device that contains the vibrator. + * + * @type { number } + */ + deviceId: number; + /** + * Unique identifier for the vibrator itself within the device. + * + * @type { number } + */ + vibratorId: number; + } + + /** + * @brief Defines the vibration effect information. + * + * The information includes the capability to set the effect and the vibration duration of the effect. + * + * @interface EffectInfo + * @since 18 + */ + interface EffectInfo { + /** + * Setting effect capability. 1 indicates support, 0 indicates not support. + * + * @type { boolean } + */ + isSupportEffect: boolean; + } + /** * Simple and universal vibration effects. * @@ -446,6 +698,16 @@ declare namespace vibrator { * @since 11 */ interface VibrateAttribute { + /** + * Unique identifier for the device that contains one or multiple vibrators, default is 0. + * + * @type { ?number } + * @syscap SystemCapability.Sensors.MiscDevice + * @atomicservice + * @since 18 + */ + deviceId?: number; + /** * Vibrator id, default is 0. * -- Gitee From 2161809acfc20f9b2cae27aac6a49e037fa29407 Mon Sep 17 00:00:00 2001 From: hero100 Date: Tue, 1 Apr 2025 17:28:39 +0800 Subject: [PATCH 02/11] miscdevice interface update new Signed-off-by: hero100 --- api/@ohos.vibrator.d.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index 328a0bd02f..c364849751 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -540,6 +540,14 @@ declare namespace vibrator { * @type { boolean } */ isSupportHdHaptic: boolean; + + /** + * Indicates whether the vibrator is a local device or an external one. + * If the value is true, it represents a local device; if false, it represents an external device. + * + * @type { boolean } + */ + isLocalVibrator: boolean; } /** @@ -554,13 +562,13 @@ declare namespace vibrator { * * @type { number } */ - deviceId: number; + deviceId?: number; /** * Unique identifier for the vibrator itself within the device. * * @type { number } */ - vibratorId: number; + vibratorId?: number; } /** -- Gitee From 104a29b689fcf498d994c361b8a88c8953670bae Mon Sep 17 00:00:00 2001 From: hero100 Date: Wed, 2 Apr 2025 09:53:06 +0800 Subject: [PATCH 03/11] miscdevice interface update new1 Signed-off-by: hero100 --- api/@ohos.vibrator.d.ts | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index c364849751..b14545b380 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -354,24 +354,11 @@ declare namespace vibrator { */ function stopVibration(param?: VibratorParam): Promise; - /** - * Stop any type of vibration. - * - * @permission ohos.permission.VIBRATE - * @param { AsyncCallback } callback - The callback of stopVibration. - * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. - * @throws { BusinessError } 201 - Permission denied. - * @syscap SystemCapability.Sensors.MiscDevice - * @atomicservice - * @since 18 - */ - function stopVibration(callback: AsyncCallback, param?: VibratorParam): void; - /** * Retrieve the list of vibrator IDs. * - * @param { AsyncCallback } callback - The callback function for retrieving vibrator ID list. * @param { VibratorParam } Param - The parameters for the vibrator. + * @returns { Promise> } Promise used to return the result for retrieving vibrator ID list. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; *
2. Incorrect parameter types; 3. Parameter verification failed. @@ -379,7 +366,7 @@ declare namespace vibrator { * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function GetVibratorList(callback: AsyncCallback>, Param?: VibratorParam): void; + function GetVibratorList(Param?: VibratorParam): Promise>; /** * Retrieve the list of vibrator IDs. @@ -399,8 +386,8 @@ declare namespace vibrator { * Retrieve effect information by device ID. * * @param { string } effectType - The effect type to retrieve. - * @param { AsyncCallback } callback - The callback function for retrieving effect information. * @param { VibratorParam } Param - The parameters for the vibrator. + * @returns { Promise> } Promise used to return the result for retrieving effect information. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; *
2. Incorrect parameter types; 3. Parameter verification failed. @@ -408,7 +395,7 @@ declare namespace vibrator { * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function isSupportEffectInfo(effectType: string, callback: AsyncCallback, Param?: VibratorParam): void; + function isSupportEffectInfo(effectType: string, Param?: VibratorParam): Promise; /** * Retrieve effect information by device ID. -- Gitee From 6d5c93eb6cbccf215bebdc73fabc31b2fcdcda27 Mon Sep 17 00:00:00 2001 From: hero100 Date: Thu, 3 Apr 2025 14:23:54 +0800 Subject: [PATCH 04/11] miscdevice interface update new2 Signed-off-by: hero100 --- api/@ohos.vibrator.d.ts | 73 ++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index b14545b380..d89912880f 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -334,6 +334,8 @@ declare namespace vibrator { * @permission ohos.permission.VIBRATE * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. * @throws { BusinessError } 14600101 - Device operation failed. * @syscap SystemCapability.Sensors.MiscDevice * @atomicservice @@ -348,6 +350,9 @@ declare namespace vibrator { * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 14600101 - Device operation failed. * @syscap SystemCapability.Sensors.MiscDevice * @atomicservice * @since 18 @@ -357,8 +362,8 @@ declare namespace vibrator { /** * Retrieve the list of vibrator IDs. * - * @param { VibratorParam } Param - The parameters for the vibrator. - * @returns { Promise> } Promise used to return the result for retrieving vibrator ID list. + * @param { VibratorParam } param - The parameter for the vibrator. + * @returns { Promise> } Promise used to return a list of vibrator IDs containing information about the vibrator device. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; *
2. Incorrect parameter types; 3. Parameter verification failed. @@ -366,13 +371,13 @@ declare namespace vibrator { * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function GetVibratorList(Param?: VibratorParam): Promise>; + function getVibratorList(param?: VibratorParam): Promise>; /** * Retrieve the list of vibrator IDs. * - * @param { VibratorParam } Param - The parameters for the vibrator. - * @returns { Array } Returns a list of vibrator IDs. + * @param { VibratorParam } param - The parameter for the vibrator. + * @returns { Array } Returns a list of vibrator IDs containing information about the vibrator device. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; *
2. Incorrect parameter types; 3. Parameter verification failed. @@ -380,14 +385,14 @@ declare namespace vibrator { * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function GetVibratorListSync(Param?: VibratorParam): Array; + function getVibratorListSync(param?: VibratorParam): Array; /** - * Retrieve effect information by device ID. + * Get effect information by device ID. * - * @param { string } effectType - The effect type to retrieve. - * @param { VibratorParam } Param - The parameters for the vibrator. - * @returns { Promise> } Promise used to return the result for retrieving effect information. + * @param { string } effectType - The effect type to query. + * @param { VibratorParam } param - The parameter for the vibrator. + * @returns { Promise } Promise used to return the result for retrieving effect information. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; *
2. Incorrect parameter types; 3. Parameter verification failed. @@ -395,13 +400,13 @@ declare namespace vibrator { * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function isSupportEffectInfo(effectType: string, Param?: VibratorParam): Promise; + function getEffectSupportInfo(effectType: string, param?: VibratorParam): Promise; /** - * Retrieve effect information by device ID. + * Get effect information by device ID. * - * @param { string } effectType - Output parameter to store the effect type. - * @param { VibratorParam } Param - The parameters for the vibrator. + * @param { string } effectType - The effect type to query. + * @param { VibratorParam } param - The parameter for the vibrator. * @returns { EffectInfo } Returns information about the specified effect. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; @@ -410,12 +415,12 @@ declare namespace vibrator { * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function isSupportEffectInfoSync(effectType: string, Param?: VibratorParam): EffectInfo; + function getEffectSupportInfoSync(effectType: string, param?: VibratorParam): EffectInfo; /** - * Registers a callback function to be called when a vibrator plung event occurs. + * Registers a callback function to be called when a vibrator plug event occurs. * - * @param { PlugEventType.VIBRATOR_PLUGIN } type - The event type corresponding to the vibrator plugin. + * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - The event type corresponding to the vibrator plugin. * @param { Callback } callback - The callback function to be executed when the event is triggered. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Callback registration failed. Possible causes: 1. Callback function is not a valid function; @@ -423,12 +428,12 @@ declare namespace vibrator { * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function on(type: PlugEventType.VIBRATOR_PLUGIN, callback: Callback): void; + function on(type: VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE, callback: Callback): void; /** - * Deregisters a callback function that listens for the vibrator unplung event. + * Deregisters a callback function that listens for the vibrator unplug event. * - * @param { PlugEventType.VIBRATOR_UNPLUG } type - The event type corresponding to the vibrator unplug. + * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - The event type corresponding to the vibrator unplug. * @param { Callback } callback - The callback function to be removed from the event listener. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Callback deregistration failed. Possible causes: 1. Callback function not previously registered; @@ -436,7 +441,7 @@ declare namespace vibrator { * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function off(type: PlugEventType.VIBRATOR_UNPLUG, callback: Callback): void; + function off(type: VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE, callback: Callback): void; /** * Interface representing the information of a vibrator device. @@ -445,7 +450,7 @@ declare namespace vibrator { * @syscap SystemCapability.Sensors.MiscDevice * @since 18 * @property { number } deviceId - Unique identifier for the device that contains one or multiple vibrators. - * @property { boolean } VibratorDeviceState - Indicates the plug state of the device; true if plugged in, false if unplugged. + * @property { boolean } vibratorDeviceState - Indicates the plug state of the device; true if plugged in, false if unplugged. */ interface VibratorDeviceInfo { /** @@ -465,39 +470,31 @@ declare namespace vibrator { * @description true if the device is plugged in; false if unplugged. * @since 18 */ - VibratorDeviceState: boolean; + vibratorDeviceState: boolean; } /** - * Enumeration representing various event types for vibrator operations. + * Enumeration representing event type for vibrator device state. * * @enum { number } * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - enum PlugEventType { - /** - * Event triggered when the vibrator is plugged in. - * - * @syscap SystemCapability.Sensors.MiscDevice - * @since 18 - */ - VIBRATOR_PLUGIN = 1, - + enum VibratorStateEventType { /** - * Event triggered when the vibrator is unplugged. + * Event triggered when the vibrator is pluged or unpluged * * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - VIBRATOR_UNPLUG = 0, + VIBRATOR_DEVICE_STATE_CHANGE = 0, } /** * @brief Represents the information about a vibrator device in the system. * * @interface VibratorInfo - * @since + * @since 18 */ interface VibratorInfo { /** @@ -561,14 +558,14 @@ declare namespace vibrator { /** * @brief Defines the vibration effect information. * - * The information includes the capability to set the effect and the vibration duration of the effect. + * The information includes Indicates whether the effect is supported. * * @interface EffectInfo * @since 18 */ interface EffectInfo { /** - * Setting effect capability. 1 indicates support, 0 indicates not support. + * Indicates whether the effect is supported, true means supported, false means not supported * * @type { boolean } */ -- Gitee From a3a4a6e460ac753299133a193abb3a7ad7e4e17a Mon Sep 17 00:00:00 2001 From: hero100 Date: Thu, 3 Apr 2025 17:21:32 +0800 Subject: [PATCH 05/11] miscdevice interface update new3 Signed-off-by: hero100 --- api/@ohos.vibrator.d.ts | 64 +++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index d89912880f..65fa063982 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -328,14 +328,23 @@ declare namespace vibrator { EFFECT_CLOCK_TIMER = 'haptic.clock.timer' } + /** + * Stop any type of vibration. + * + * @permission ohos.permission.VIBRATE + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 14600101 - Device operation failed. + * @syscap SystemCapability.Sensors.MiscDevice + * @atomicservice + * @since 12 + */ /** * Stop any type of vibration. * * @permission ohos.permission.VIBRATE * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed. * @throws { BusinessError } 14600101 - Device operation failed. * @syscap SystemCapability.Sensors.MiscDevice * @atomicservice @@ -343,6 +352,16 @@ declare namespace vibrator { */ function stopVibrationSync(param?: VibratorParam): void; + /** + * Stop any type of vibration. + * + * @permission ohos.permission.VIBRATE + * @returns { Promise } Promise used to return the result. + * @throws { BusinessError } 201 - Permission denied. + * @syscap SystemCapability.Sensors.MiscDevice + * @atomicservice + * @since 11 + */ /** * Stop any type of vibration. * @@ -350,8 +369,7 @@ declare namespace vibrator { * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed. * @throws { BusinessError } 14600101 - Device operation failed. * @syscap SystemCapability.Sensors.MiscDevice * @atomicservice @@ -360,13 +378,12 @@ declare namespace vibrator { function stopVibration(param?: VibratorParam): Promise; /** - * Retrieve the list of vibrator IDs. + * Retrieve the list of vibrator information about a vibrator device. * - * @param { VibratorParam } param - The parameter for the vibrator. + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. * @returns { Promise> } Promise used to return a list of vibrator IDs containing information about the vibrator device. * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed. * @throws { BusinessError } 14600101 - Device operation failed. * @syscap SystemCapability.Sensors.MiscDevice * @since 18 @@ -374,13 +391,12 @@ declare namespace vibrator { function getVibratorList(param?: VibratorParam): Promise>; /** - * Retrieve the list of vibrator IDs. + * Retrieve the list of vibrator information about a vibrator device. * - * @param { VibratorParam } param - The parameter for the vibrator. + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. * @returns { Array } Returns a list of vibrator IDs containing information about the vibrator device. * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed. * @throws { BusinessError } 14600101 - Device operation failed. * @syscap SystemCapability.Sensors.MiscDevice * @since 18 @@ -391,7 +407,7 @@ declare namespace vibrator { * Get effect information by device ID. * * @param { string } effectType - The effect type to query. - * @param { VibratorParam } param - The parameter for the vibrator. + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. * @returns { Promise } Promise used to return the result for retrieving effect information. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; @@ -406,7 +422,7 @@ declare namespace vibrator { * Get effect information by device ID. * * @param { string } effectType - The effect type to query. - * @param { VibratorParam } param - The parameter for the vibrator. + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. * @returns { EffectInfo } Returns information about the specified effect. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; @@ -418,9 +434,9 @@ declare namespace vibrator { function getEffectSupportInfoSync(effectType: string, param?: VibratorParam): EffectInfo; /** - * Registers a callback function to be called when a vibrator plug event occurs. + * Register a callback function to be called when a vibrator insertion or removal event occurs. * - * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - The event type corresponding to the vibrator plugin. + * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - Event type indicating vibrator device state changes. * @param { Callback } callback - The callback function to be executed when the event is triggered. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Callback registration failed. Possible causes: 1. Callback function is not a valid function; @@ -431,9 +447,9 @@ declare namespace vibrator { function on(type: VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE, callback: Callback): void; /** - * Deregisters a callback function that listens for the vibrator unplug event. + * Deregister a callback function for vibrator insertion or removal events. * - * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - The event type corresponding to the vibrator unplug. + * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - Event type indicating vibrator device state changes. * @param { Callback } callback - The callback function to be removed from the event listener. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Callback deregistration failed. Possible causes: 1. Callback function not previously registered; @@ -536,21 +552,24 @@ declare namespace vibrator { /** * @brief Represents the parameters for querying vibrator information. + * By default, VibratorParam may default to querying or controlling the local default vibrator. * * @interface VibratorParam * @since 18 */ interface VibratorParam { /** - * Unique identifier for the device that contains the vibrator. + * Unique identifier for the device that contains one or multiple vibrators. + * By default, deviceId may default to querying or controlling the local default vibrator. * - * @type { number } + * @type { ?number } */ deviceId?: number; /** * Unique identifier for the vibrator itself within the device. + * By default, vibratorId may default to querying or controlling all vibrators on the corresponding device. * - * @type { number } + * @type { ?number } */ vibratorId?: number; } @@ -691,7 +710,8 @@ declare namespace vibrator { */ interface VibrateAttribute { /** - * Unique identifier for the device that contains one or multiple vibrators, default is 0. + * Unique identifier for the device that contains one or multiple vibrators. + * By default, deviceId represents the default device of the local device. * * @type { ?number } * @syscap SystemCapability.Sensors.MiscDevice -- Gitee From 45f98b7e560ee5686290916a200c09ba6ad9199e Mon Sep 17 00:00:00 2001 From: hero100 Date: Thu, 3 Apr 2025 18:50:06 +0800 Subject: [PATCH 06/11] miscdevice interface update new4 Signed-off-by: hero100 --- api/@ohos.vibrator.d.ts | 126 ++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 69 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index 65fa063982..db04b08060 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -222,7 +222,22 @@ declare namespace vibrator { * @atomicservice * @since 11 */ - function stopVibration(): Promise; + /** + * Stop any type of vibration. + * + * @permission ohos.permission.VIBRATE + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, + *
{@code VibratorParam}. + * @returns { Promise } Promise used to return the result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; + *
2. Parameter verification failed. + * @throws { BusinessError } 14600101 - Device operation failed. + * @syscap SystemCapability.Sensors.MiscDevice + * @atomicservice + * @since 18 + */ + function stopVibration(param?: VibratorParam): Promise; /** * Stop any type of vibration. @@ -234,7 +249,21 @@ declare namespace vibrator { * @atomicservice * @since 12 */ - function stopVibrationSync(): void; + /** + * Stop any type of vibration. + * + * @permission ohos.permission.VIBRATE + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, + *
{@code VibratorParam}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; + *
2. Parameter verification failed. + * @throws { BusinessError } 14600101 - Device operation failed. + * @syscap SystemCapability.Sensors.MiscDevice + * @atomicservice + * @since 18 + */ + function stopVibrationSync(param?: VibratorParam): void; /** * Whether the preset vibration effect is supported. @@ -328,62 +357,16 @@ declare namespace vibrator { EFFECT_CLOCK_TIMER = 'haptic.clock.timer' } - /** - * Stop any type of vibration. - * - * @permission ohos.permission.VIBRATE - * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 14600101 - Device operation failed. - * @syscap SystemCapability.Sensors.MiscDevice - * @atomicservice - * @since 12 - */ - /** - * Stop any type of vibration. - * - * @permission ohos.permission.VIBRATE - * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. - * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed. - * @throws { BusinessError } 14600101 - Device operation failed. - * @syscap SystemCapability.Sensors.MiscDevice - * @atomicservice - * @since 18 - */ - function stopVibrationSync(param?: VibratorParam): void; - - /** - * Stop any type of vibration. - * - * @permission ohos.permission.VIBRATE - * @returns { Promise } Promise used to return the result. - * @throws { BusinessError } 201 - Permission denied. - * @syscap SystemCapability.Sensors.MiscDevice - * @atomicservice - * @since 11 - */ - /** - * Stop any type of vibration. - * - * @permission ohos.permission.VIBRATE - * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. - * @returns { Promise } Promise used to return the result. - * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed. - * @throws { BusinessError } 14600101 - Device operation failed. - * @syscap SystemCapability.Sensors.MiscDevice - * @atomicservice - * @since 18 - */ - function stopVibration(param?: VibratorParam): Promise; - /** * Retrieve the list of vibrator information about a vibrator device. * - * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. - * @returns { Promise> } Promise used to return a list of vibrator IDs containing information about the vibrator device. + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, + *
{@code VibratorParam}. + * @returns { Promise> } Promise used to return a list of vibrator IDs containing information + *
about the vibrator device. * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; + *
2. Parameter verification failed. * @throws { BusinessError } 14600101 - Device operation failed. * @syscap SystemCapability.Sensors.MiscDevice * @since 18 @@ -393,10 +376,12 @@ declare namespace vibrator { /** * Retrieve the list of vibrator information about a vibrator device. * - * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, + *
{@code VibratorParam}. * @returns { Array } Returns a list of vibrator IDs containing information about the vibrator device. * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; + *
2. Parameter verification failed. * @throws { BusinessError } 14600101 - Device operation failed. * @syscap SystemCapability.Sensors.MiscDevice * @since 18 @@ -407,7 +392,8 @@ declare namespace vibrator { * Get effect information by device ID. * * @param { string } effectType - The effect type to query. - * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, + *
{@code VibratorParam}. * @returns { Promise } Promise used to return the result for retrieving effect information. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; @@ -422,7 +408,8 @@ declare namespace vibrator { * Get effect information by device ID. * * @param { string } effectType - The effect type to query. - * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParam}. + * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, + *
{@code VibratorParam}. * @returns { EffectInfo } Returns information about the specified effect. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; @@ -434,26 +421,29 @@ declare namespace vibrator { function getEffectSupportInfoSync(effectType: string, param?: VibratorParam): EffectInfo; /** - * Register a callback function to be called when a vibrator insertion or removal event occurs. + * Register a callback function to be called when a vibrator plugin or unplug event occurs. * - * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - Event type indicating vibrator device state changes. - * @param { Callback } callback - The callback function to be executed when the event is triggered. + * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - Event type indicating vibrator + *
device state changes. + * @param { Callback } callback - The callback function to be executed when + *
the event is triggered. * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Callback registration failed. Possible causes: 1. Callback function is not a valid function; - *
2. Insufficient permissions to register the callback. + * @throws { BusinessError } 401 - Callback registration failed. Possible causes: 1. Callback function is + *
not a valid function; 2. Insufficient permissions to register the callback. * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ function on(type: VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE, callback: Callback): void; /** - * Deregister a callback function for vibrator insertion or removal events. + * Unregister a callback function for vibrator plugin or unplug events. * - * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - Event type indicating vibrator device state changes. + * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - Event type indicating vibrator + *
device state changes. * @param { Callback } callback - The callback function to be removed from the event listener. * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Callback deregistration failed. Possible causes: 1. Callback function not previously registered; - *
2. Insufficient permissions to deregister the callback. + * @throws { BusinessError } 401 - Callback registration failed. Possible causes: 1. Callback function is + *
not a valid function; 2. Insufficient permissions to register the callback. * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ @@ -465,8 +455,6 @@ declare namespace vibrator { * @interface * @syscap SystemCapability.Sensors.MiscDevice * @since 18 - * @property { number } deviceId - Unique identifier for the device that contains one or multiple vibrators. - * @property { boolean } vibratorDeviceState - Indicates the plug state of the device; true if plugged in, false if unplugged. */ interface VibratorDeviceInfo { /** -- Gitee From 7e40ac089fcc532def0ac87caf0c81c8f35243ca Mon Sep 17 00:00:00 2001 From: hero100 Date: Mon, 7 Apr 2025 11:35:15 +0800 Subject: [PATCH 07/11] miscdevice interface update new5 Signed-off-by: hero100 --- api/@ohos.vibrator.d.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index db04b08060..bd2c48b8c4 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -358,12 +358,12 @@ declare namespace vibrator { } /** - * Retrieve the list of vibrator information about a vibrator device. + * Retrieve the list of vibrator information about one or all devices. * * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, *
{@code VibratorParam}. * @returns { Promise> } Promise used to return a list of vibrator IDs containing information - *
about the vibrator device. + *
about the vibrator device.By default, this returns all devices and all vibrators when param is unspecified. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; *
2. Parameter verification failed. @@ -374,11 +374,12 @@ declare namespace vibrator { function getVibratorList(param?: VibratorParam): Promise>; /** - * Retrieve the list of vibrator information about a vibrator device. + * Retrieve the list of vibrator information about one or all devices. * * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, *
{@code VibratorParam}. - * @returns { Array } Returns a list of vibrator IDs containing information about the vibrator device. + * @returns { Array } Returns a list of vibrator IDs containing information + *
about the vibrator device.By default, this returns all devices and all vibrators when param is unspecified. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; *
2. Parameter verification failed. @@ -505,6 +506,7 @@ declare namespace vibrator { * Unique identifier for the device that contains one or multiple vibrators. * * @type { number } + * @since 18 */ deviceId: number; @@ -512,6 +514,7 @@ declare namespace vibrator { * Unique identifier for the vibrator itself within the device. * * @type { number } + * @since 18 */ vibratorId: number; @@ -519,6 +522,7 @@ declare namespace vibrator { * Name of the device. * * @type { string } + * @since 18 */ deviceName: string; @@ -526,6 +530,7 @@ declare namespace vibrator { * Indicates if the vibrator device support HD haptic. * * @type { boolean } + * @since 18 */ isSupportHdHaptic: boolean; @@ -534,6 +539,7 @@ declare namespace vibrator { * If the value is true, it represents a local device; if false, it represents an external device. * * @type { boolean } + * @since 18 */ isLocalVibrator: boolean; } @@ -551,6 +557,7 @@ declare namespace vibrator { * By default, deviceId may default to querying or controlling the local default vibrator. * * @type { ?number } + * @since 18 */ deviceId?: number; /** @@ -558,6 +565,7 @@ declare namespace vibrator { * By default, vibratorId may default to querying or controlling all vibrators on the corresponding device. * * @type { ?number } + * @since 18 */ vibratorId?: number; } @@ -575,6 +583,7 @@ declare namespace vibrator { * Indicates whether the effect is supported, true means supported, false means not supported * * @type { boolean } + * @since 18 */ isSupportEffect: boolean; } -- Gitee From 3c49428faecd30fc48cde53547a5068b18e06eb2 Mon Sep 17 00:00:00 2001 From: hero100 Date: Wed, 9 Apr 2025 09:42:10 +0800 Subject: [PATCH 08/11] miscdevice interface update new6 Signed-off-by: hero100 --- api/@ohos.vibrator.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index bd2c48b8c4..dee1ea7f73 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -445,6 +445,7 @@ declare namespace vibrator { * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Callback registration failed. Possible causes: 1. Callback function is *
not a valid function; 2. Insufficient permissions to register the callback. + * @throws { BusinessError } 14600102 - The user callback function has been deregistered. * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ -- Gitee From d86154d58d27d38909c48c61d30853d45a32b06f Mon Sep 17 00:00:00 2001 From: hero100 Date: Wed, 9 Apr 2025 11:43:01 +0800 Subject: [PATCH 09/11] miscdevice interface update new7 Signed-off-by: hero100 --- api/@ohos.vibrator.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index dee1ea7f73..936f4e2f62 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -428,8 +428,7 @@ declare namespace vibrator { *
device state changes. * @param { Callback } callback - The callback function to be executed when *
the event is triggered. - * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Callback registration failed. Possible causes: 1. Callback function is + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Callback function is *
not a valid function; 2. Insufficient permissions to register the callback. * @syscap SystemCapability.Sensors.MiscDevice * @since 18 @@ -442,8 +441,7 @@ declare namespace vibrator { * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - Event type indicating vibrator *
device state changes. * @param { Callback } callback - The callback function to be removed from the event listener. - * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Callback registration failed. Possible causes: 1. Callback function is + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Callback function is *
not a valid function; 2. Insufficient permissions to register the callback. * @throws { BusinessError } 14600102 - The user callback function has been deregistered. * @syscap SystemCapability.Sensors.MiscDevice -- Gitee From 0d6389eddb6b3f8e358c255889b3b5080ba423a6 Mon Sep 17 00:00:00 2001 From: hero100 Date: Tue, 6 May 2025 14:11:47 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/@ohos.vibrator.d.ts | 43 +++++------------------------------------ 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index 936f4e2f62..43bfaaaa86 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -249,21 +249,7 @@ declare namespace vibrator { * @atomicservice * @since 12 */ - /** - * Stop any type of vibration. - * - * @permission ohos.permission.VIBRATE - * @param { VibratorParam } param - Indicate the device and vibrator information that needs to be controlled, - *
{@code VibratorParam}. - * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; - *
2. Parameter verification failed. - * @throws { BusinessError } 14600101 - Device operation failed. - * @syscap SystemCapability.Sensors.MiscDevice - * @atomicservice - * @since 18 - */ - function stopVibrationSync(param?: VibratorParam): void; + function stopVibrationSync(): void; /** * Whether the preset vibration effect is supported. @@ -424,8 +410,7 @@ declare namespace vibrator { /** * Register a callback function to be called when a vibrator plugin or unplug event occurs. * - * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - Event type indicating vibrator - *
device state changes. + * @param { 'VibratorDeviceStateChange' } type - event of the listening * @param { Callback } callback - The callback function to be executed when *
the event is triggered. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Callback function is @@ -433,13 +418,12 @@ declare namespace vibrator { * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function on(type: VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE, callback: Callback): void; + function on(type: 'VibratorDeviceStateChange', callback: Callback): void; /** * Unregister a callback function for vibrator plugin or unplug events. * - * @param { VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE } type - Event type indicating vibrator - *
device state changes. + * @param { 'VibratorDeviceStateChange' } type - event of the listening * @param { Callback } callback - The callback function to be removed from the event listener. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Callback function is *
not a valid function; 2. Insufficient permissions to register the callback. @@ -447,7 +431,7 @@ declare namespace vibrator { * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function off(type: VibratorStateEventType.VIBRATOR_DEVICE_STATE_CHANGE, callback: Callback): void; + function off(type: 'VibratorDeviceStateChange', callback: Callback): void; /** * Interface representing the information of a vibrator device. @@ -475,23 +459,6 @@ declare namespace vibrator { * @since 18 */ vibratorDeviceState: boolean; - } - - /** - * Enumeration representing event type for vibrator device state. - * - * @enum { number } - * @syscap SystemCapability.Sensors.MiscDevice - * @since 18 - */ - enum VibratorStateEventType { - /** - * Event triggered when the vibrator is pluged or unpluged - * - * @syscap SystemCapability.Sensors.MiscDevice - * @since 18 - */ - VIBRATOR_DEVICE_STATE_CHANGE = 0, } /** -- Gitee From 92f424b7bcd7c4b239e5f6b5ce5b459fd8459390 Mon Sep 17 00:00:00 2001 From: hero100 Date: Tue, 6 May 2025 14:16:07 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=A1=E6=81=AF1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/@ohos.vibrator.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index 43bfaaaa86..248e72501b 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -410,7 +410,7 @@ declare namespace vibrator { /** * Register a callback function to be called when a vibrator plugin or unplug event occurs. * - * @param { 'VibratorDeviceStateChange' } type - event of the listening + * @param { 'VibratorDeviceStateChange' } type - Event of the listening * @param { Callback } callback - The callback function to be executed when *
the event is triggered. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Callback function is @@ -423,7 +423,7 @@ declare namespace vibrator { /** * Unregister a callback function for vibrator plugin or unplug events. * - * @param { 'VibratorDeviceStateChange' } type - event of the listening + * @param { 'VibratorDeviceStateChange' } type - Event of the listening * @param { Callback } callback - The callback function to be removed from the event listener. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Callback function is *
not a valid function; 2. Insufficient permissions to register the callback. -- Gitee