From 4ae14c01b1ae333326679da19dbf8a9f49267567 Mon Sep 17 00:00:00 2001 From: hero100 Date: Sat, 29 Mar 2025 17:22:13 +0800 Subject: [PATCH 1/2] miscdevice interface update Signed-off-by: hero100 --- api/@ohos.vibrator.d.ts | 416 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 408 insertions(+), 8 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index 8d08f4fea8..6040bc15fd 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. @@ -319,13 +319,301 @@ declare namespace vibrator { * @since 8 */ enum EffectId { + /** + * Describes the vibration effect of the vibrator when a user adjusts the timer. + * + * @syscap SystemCapability.Sensors.MiscDevice + * @since 8 + */ + EFFECT_CLOCK_TIMER = 'haptic.clock.timer' + } + + /** + * Stop any type of vibration. + * + * @permission ohos.permission.VIBRATE + * @param { VibratorParams } params - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParams}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 14600101 - Device operation failed. + * @syscap SystemCapability.Sensors.MiscDevice + * @atomicservice + * @since 18 + */ + function stopVibrationSync(params: VibratorParams): void; + /** - * Describes the vibration effect of the vibrator when a user adjusts the timer. + * Stop any type of vibration. * + * @permission ohos.permission.VIBRATE + * @param { VibratorParams } params - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParams}. + * @returns { Promise } Promise used to return the result. + * @throws { BusinessError } 201 - Permission denied. * @syscap SystemCapability.Sensors.MiscDevice - * @since 8 + * @atomicservice + * @since 18 + */ + function stopVibration(params: VibratorParams): Promise; + + /** + * Stop any type of vibration. + * + * @permission ohos.permission.VIBRATE + * @param { VibratorParams } params - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParams}. + * @param { AsyncCallback } callback - The callback of stopVibration. + * @throws { BusinessError } 201 - Permission denied. + * @syscap SystemCapability.Sensors.MiscDevice + * @atomicservice + * @since 18 + */ + function stopVibration(params: VibratorParams, callback: AsyncCallback): void; + +/** + * Stop the vibrator from vibrating. + * + * @permission ohos.permission.VIBRATE + * @param { VibratorParams } params - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParams}. + * @param { VibratorStopMode } stopMode - Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}. + * @param { AsyncCallback } callback - The callback of stopVibration. + * @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. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ +function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callback: AsyncCallback): void; + + /** + * Stop the vibrator from vibrating. + * + * @permission ohos.permission.VIBRATE + * @param { VibratorParams } params - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParams}. + * @param { VibratorStopMode } stopMode - Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}. + * @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. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + function stopVibration(params: VibratorParams, stopMode: VibratorStopMode): Promise; + + /** + * Retrieve the list of vibrator IDs. + * + * @param { VibratorParams } Params - The parameters for the vibrator. + * @param { AsyncCallback } callback - The callback function 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. + * @throws { BusinessError } 14600101 - Device operation failed. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + function GetVibratorIdList(Params: VibratorParams, callback: AsyncCallback>): void; + + /** + * Retrieve effect information by device ID. + * + * @param { VibratorParams } Params - The parameters for the vibrator. + * @param { string } effectType - The effect type to retrieve. + * @param { AsyncCallback } callback - The callback function 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. + * @throws { BusinessError } 14600101 - Device operation failed. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + function isSupportEffectInfo(Params: VibratorParams, effectType: string, callback: AsyncCallback): void; + + /** + * Retrieve the list of vibrator IDs. + * + * @param { VibratorParams } Params - 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 GetVibratorIdListSync(Params: VibratorParams): Array; + + /** + * Retrieve effect information by device ID. + * + * @param { VibratorParams } Params - The parameters for the vibrator. + * @param { string } effectType - Output parameter to store the effect type. + * @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(Params: VibratorParams, effectType: string): EffectInfo; + + /** + * Registers a callback function to be called when a vibrator plung event occurs. + * + * @param { EventType.VIBRATOR_PLUNG } type - The event type corresponding to the vibrator plung. + * @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: EventType.VIBRATOR_PLUNG, callback: Callback): void; + + /** + * Deregisters a callback function that listens for the vibrator unplung event. + * + * @param { EventType.VIBRATOR_UNPLUNG } type - The event type corresponding to the vibrator unplung. + * @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: EventType.VIBRATOR_UNPLUNG, callback: Callback): void; + +/** + * Interface representing the information of a vibrator device. + * + * @interface + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + * @property { boolean } VibratorPlugState - Indicates the plug state of the vibrator; true if plugged in, false if unplugged. + * @property { number } deviceId - The unique identifier for the vibrator device. + */ + interface VibratorDeviceInfo { + /** + * Indicates the plug state of the vibrator. + * + * @type { boolean } + * @default false + * @description true if the device is plugged in; false if unplugged. + * @since 18 + */ + VibratorPlugState: boolean; + + /** + * The unique identifier for the vibrator device. + * + * @type { number } + * @description A numeric value that serves as the unique identifier for the device. + * @since 18 + */ + deviceId: number; + } + + /** + * Enumeration representing various event types for vibrator operations. + * + * @enum { number } + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + enum EventType { + /** + * Event triggered when the vibrator is plugged in. + * + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + VIBRATOR_PLUNG = 0, + + /** + * Event triggered when the vibrator is unplugged. + * + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + VIBRATOR_UNPLUNG = 1, + } + + /** + * @brief Represents the information about a vibrator device in the system. + * + * @interface VibratorInfos + * @since */ - EFFECT_CLOCK_TIMER = 'haptic.clock.timer' + interface VibratorInfos { + /** + * 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; + + /** + * Human-readable name of the device. + * + * @type { string } + */ + deviceName: string; + + /** + * Indicates the vibration support HD vibration. + * + * @type { boolean } + */ + isSupportHdHaptic: boolean; + } + + /** + * @brief Represents the parameters for querying vibrator information. + * + * @interface VibratorParams + * @since + */ + interface VibratorParams { + /** + * 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 + */ + interface EffectInfo { + /** + * Vibration duration of the effect, in milliseconds. + * + * @type { number } + */ + duration: number; + /** + * Setting effect capability. 1 indicates support, 0 indicates not support. + * + * @type { boolean } + */ + isSupportEffect: boolean; } /** @@ -427,8 +715,77 @@ declare namespace vibrator { * @atomicservice * @since 11 */ - type Usage = 'unknown' | 'alarm' | 'ring' | 'notification' | 'communication' | - 'touch' | 'media' | 'physicalFeedback' | 'simulateReality'; + /** + * Enumeration representing the various usage types for devices. + * + * @enum { string } + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + enum Usage { + /** + * Indicates an unknown usage type. + * + * @since 18 + */ + UNKNOWN = 'unknown', + + /** + * Indicates the usage type for alarms. + * + * @since 18 + */ + ALARM = 'alarm', + + /** + * Indicates the usage type for ringing. + * + * @since 18 + */ + RING = 'ring', + + /** + * Indicates the usage type for notifications. + * + * @since 18 + */ + NOTIFICATION = 'notification', + + /** + * Indicates the usage type for communication. + * + * @since 18 + */ + COMMUNICATION = 'communication', + + /** + * Indicates the usage type for touch interactions. + * + * @since 18 + */ + TOUCH = 'touch', + + /** + * Indicates the usage type for media playback. + * + * @since 18 + */ + MEDIA = 'media', + + /** + * Indicates the usage type for physical feedback. + * + * @since 18 + */ + PHYSICAL_FEEDBACK = 'physicalFeedback', + + /** + * Indicates the usage type for simulating reality. + * + * @since 18 + */ + SIMULATE_REALITY = 'simulateReality' + } /** * The attribute of vibration. @@ -446,6 +803,15 @@ declare namespace vibrator { * @since 11 */ interface VibrateAttribute { + /** + * Device id, default is 0. + * + * @type { ?number } + * @syscap SystemCapability.Sensors.MiscDevice + * @atomicservice + * @since 18 + */ + deviceId?: number; /** * Vibrator id, default is 0. * @@ -461,7 +827,6 @@ declare namespace vibrator { * @since 11 */ id?: number; - /** * The use of vibration. * @@ -519,7 +884,42 @@ declare namespace vibrator { * @atomicservice * @since 18 */ - type VibrateEffect = VibrateTime | VibratePreset | VibrateFromFile | VibrateFromPattern; + /** + * Enumeration representing the various vibration effects. + * + * @enum { string } + * @syscap SystemCapability.Sensors.MiscDevice + * @since 18 + */ + enum VibrateEffect { + /** + * Represents a vibration effect defined by a specific duration. + * + * @since 18 + */ + VIBRATE_TIME = 'VibrateTime', + + /** + * Represents a predefined vibration pattern. + * + * @since 18 + */ + VIBRATE_PRESET = 'VibratePreset', + + /** + * Represents a vibration effect sourced from a file. + * + * @since 18 + */ + VIBRATE_FROM_FILE = 'VibrateFromFile', + + /** + * Represents a vibration effect defined by a specific pattern. + * + * @since 18 + */ + VIBRATE_FROM_PATTERN = 'VibrateFromPattern' + } /** * Vibrate continuously for a period of time at the default intensity of the system. -- Gitee From cf9bf3832579c9bd32464d9b5657acc6ed1bb080 Mon Sep 17 00:00:00 2001 From: hero100 Date: Mon, 31 Mar 2025 11:20:06 +0800 Subject: [PATCH 2/2] miscdevice interface update(new) Signed-off-by: hero100 --- api/@ohos.vibrator.d.ts | 270 ++++++++++------------------------------ 1 file changed, 66 insertions(+), 204 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index 6040bc15fd..8e66128aa0 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -319,89 +319,73 @@ declare namespace vibrator { * @since 8 */ enum EffectId { - /** - * Describes the vibration effect of the vibrator when a user adjusts the timer. - * - * @syscap SystemCapability.Sensors.MiscDevice - * @since 8 - */ - EFFECT_CLOCK_TIMER = 'haptic.clock.timer' + /** + * Describes the vibration effect of the vibrator when a user adjusts the timer. + * + * @syscap SystemCapability.Sensors.MiscDevice + * @since 8 + */ + EFFECT_CLOCK_TIMER = 'haptic.clock.timer' } - /** + /** * Stop any type of vibration. * * @permission ohos.permission.VIBRATE - * @param { VibratorParams } params - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParams}. + * @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(params: VibratorParams): void; + function stopVibrationSync(param?: VibratorParam): void; /** * Stop any type of vibration. * * @permission ohos.permission.VIBRATE - * @param { VibratorParams } params - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParams}. + * @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(params: VibratorParams): Promise; + function stopVibration(param?: VibratorParam): Promise; /** * Stop any type of vibration. * * @permission ohos.permission.VIBRATE - * @param { VibratorParams } params - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParams}. * @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(params: VibratorParams, callback: AsyncCallback): void; - -/** - * Stop the vibrator from vibrating. - * - * @permission ohos.permission.VIBRATE - * @param { VibratorParams } params - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParams}. - * @param { VibratorStopMode } stopMode - Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}. - * @param { AsyncCallback } callback - The callback of stopVibration. - * @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. - * @syscap SystemCapability.Sensors.MiscDevice - * @since 18 - */ -function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callback: AsyncCallback): void; + function stopVibration(callback: AsyncCallback, param?: VibratorParam): void; /** - * Stop the vibrator from vibrating. + * Retrieve the list of vibrator IDs. * - * @permission ohos.permission.VIBRATE - * @param { VibratorParams } params - Indicate the device and vibrator information that needs to be controlled, {@code VibratorParams}. - * @param { VibratorStopMode } stopMode - Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}. - * @returns { Promise } Promise used to return the result. + * @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 stopVibration(params: VibratorParams, stopMode: VibratorStopMode): Promise; + function GetVibratorList(callback: AsyncCallback>, Param?: VibratorParam): void; /** * Retrieve the list of vibrator IDs. * - * @param { VibratorParams } Params - The parameters for the vibrator. - * @param { AsyncCallback } callback - The callback function for retrieving vibrator ID list. + * @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. @@ -409,14 +393,14 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function GetVibratorIdList(Params: VibratorParams, callback: AsyncCallback>): void; + function GetVibratorListSync(Param?: VibratorParam): Array; /** * Retrieve effect information by device ID. * - * @param { VibratorParams } Params - The parameters for the vibrator. * @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. @@ -424,27 +408,13 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function isSupportEffectInfo(Params: VibratorParams, effectType: string, callback: AsyncCallback): void; - - /** - * Retrieve the list of vibrator IDs. - * - * @param { VibratorParams } Params - 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 GetVibratorIdListSync(Params: VibratorParams): Array; + function isSupportEffectInfo(effectType: string, callback: AsyncCallback, Param?: VibratorParam): void; /** * Retrieve effect information by device ID. * - * @param { VibratorParams } Params - The parameters for the vibrator. * @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; @@ -453,12 +423,12 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function isSupportEffectInfoSync(Params: VibratorParams, effectType: string): EffectInfo; + function isSupportEffectInfoSync(effectType: string, Param?: VibratorParam): EffectInfo; /** * Registers a callback function to be called when a vibrator plung event occurs. * - * @param { EventType.VIBRATOR_PLUNG } type - The event type corresponding to the vibrator plung. + * @param { EventType.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; @@ -466,12 +436,12 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function on(type: EventType.VIBRATOR_PLUNG, callback: Callback): void; + function on(type: EventType.VIBRATOR_PLUGIN, callback: Callback): void; /** * Deregisters a callback function that listens for the vibrator unplung event. * - * @param { EventType.VIBRATOR_UNPLUNG } type - The event type corresponding to the vibrator unplung. + * @param { EventType.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; @@ -479,36 +449,36 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - function off(type: EventType.VIBRATOR_UNPLUNG, callback: Callback): void; + function off(type: EventType.VIBRATOR_UNPLUG, callback: Callback): void; -/** - * Interface representing the information of a vibrator device. - * - * @interface - * @syscap SystemCapability.Sensors.MiscDevice - * @since 18 - * @property { boolean } VibratorPlugState - Indicates the plug state of the vibrator; true if plugged in, false if unplugged. - * @property { number } deviceId - The unique identifier for the vibrator device. - */ + /** + * 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 { /** - * Indicates the plug state of the vibrator. - * - * @type { boolean } - * @default false - * @description true if the device is plugged in; false if unplugged. - * @since 18 - */ - VibratorPlugState: boolean; - - /** - * The unique identifier for the vibrator device. + * 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; } /** @@ -525,7 +495,7 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - VIBRATOR_PLUNG = 0, + VIBRATOR_PLUGIN = 1, /** * Event triggered when the vibrator is unplugged. @@ -533,7 +503,7 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb * @syscap SystemCapability.Sensors.MiscDevice * @since 18 */ - VIBRATOR_UNPLUNG = 1, + VIBRATOR_UNPLUG = 0, } /** @@ -544,7 +514,7 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb */ interface VibratorInfos { /** - * Unique identifier for the device that contains the vibrator. + * Unique identifier for the device that contains one or multiple vibrators. * * @type { number } */ @@ -558,14 +528,14 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb vibratorId: number; /** - * Human-readable name of the device. + * Name of the device. * * @type { string } */ deviceName: string; /** - * Indicates the vibration support HD vibration. + * Indicates if the vibrator device support HD haptic. * * @type { boolean } */ @@ -575,10 +545,10 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb /** * @brief Represents the parameters for querying vibrator information. * - * @interface VibratorParams - * @since + * @interface VibratorParam + * @since 18 */ - interface VibratorParams { + interface VibratorParam { /** * Unique identifier for the device that contains the vibrator. * @@ -599,15 +569,9 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb * The information includes the capability to set the effect and the vibration duration of the effect. * * @interface EffectInfo - * @since + * @since 18 */ interface EffectInfo { - /** - * Vibration duration of the effect, in milliseconds. - * - * @type { number } - */ - duration: number; /** * Setting effect capability. 1 indicates support, 0 indicates not support. * @@ -715,77 +679,8 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb * @atomicservice * @since 11 */ - /** - * Enumeration representing the various usage types for devices. - * - * @enum { string } - * @syscap SystemCapability.Sensors.MiscDevice - * @since 18 - */ - enum Usage { - /** - * Indicates an unknown usage type. - * - * @since 18 - */ - UNKNOWN = 'unknown', - - /** - * Indicates the usage type for alarms. - * - * @since 18 - */ - ALARM = 'alarm', - - /** - * Indicates the usage type for ringing. - * - * @since 18 - */ - RING = 'ring', - - /** - * Indicates the usage type for notifications. - * - * @since 18 - */ - NOTIFICATION = 'notification', - - /** - * Indicates the usage type for communication. - * - * @since 18 - */ - COMMUNICATION = 'communication', - - /** - * Indicates the usage type for touch interactions. - * - * @since 18 - */ - TOUCH = 'touch', - - /** - * Indicates the usage type for media playback. - * - * @since 18 - */ - MEDIA = 'media', - - /** - * Indicates the usage type for physical feedback. - * - * @since 18 - */ - PHYSICAL_FEEDBACK = 'physicalFeedback', - - /** - * Indicates the usage type for simulating reality. - * - * @since 18 - */ - SIMULATE_REALITY = 'simulateReality' - } + type Usage = 'unknown' | 'alarm' | 'ring' | 'notification' | 'communication' | + 'touch' | 'media' | 'physicalFeedback' | 'simulateReality'; /** * The attribute of vibration. @@ -804,14 +699,15 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb */ interface VibrateAttribute { /** - * Device id, default is 0. + * 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; + deviceId?: number; + /** * Vibrator id, default is 0. * @@ -827,6 +723,7 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb * @since 11 */ id?: number; + /** * The use of vibration. * @@ -884,42 +781,7 @@ function stopVibration(params: VibratorParams, stopMode: VibratorStopMode, callb * @atomicservice * @since 18 */ - /** - * Enumeration representing the various vibration effects. - * - * @enum { string } - * @syscap SystemCapability.Sensors.MiscDevice - * @since 18 - */ - enum VibrateEffect { - /** - * Represents a vibration effect defined by a specific duration. - * - * @since 18 - */ - VIBRATE_TIME = 'VibrateTime', - - /** - * Represents a predefined vibration pattern. - * - * @since 18 - */ - VIBRATE_PRESET = 'VibratePreset', - - /** - * Represents a vibration effect sourced from a file. - * - * @since 18 - */ - VIBRATE_FROM_FILE = 'VibrateFromFile', - - /** - * Represents a vibration effect defined by a specific pattern. - * - * @since 18 - */ - VIBRATE_FROM_PATTERN = 'VibrateFromPattern' - } + type VibrateEffect = VibrateTime | VibratePreset | VibrateFromFile | VibrateFromPattern; /** * Vibrate continuously for a period of time at the default intensity of the system. -- Gitee