161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit SensorServiceKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport { AsyncCallback } from './@ohos.base';
2261847f8eSopenharmony_ci
2361847f8eSopenharmony_ci/**
2461847f8eSopenharmony_ci * This module provides the capability to control motor vibration.
2561847f8eSopenharmony_ci *
2661847f8eSopenharmony_ci * @namespace vibrator
2761847f8eSopenharmony_ci * @syscap SystemCapability.Sensors.MiscDevice
2861847f8eSopenharmony_ci * @since 8
2961847f8eSopenharmony_ci */
3061847f8eSopenharmony_ci/**
3161847f8eSopenharmony_ci * This module provides the capability to control motor vibration.
3261847f8eSopenharmony_ci *
3361847f8eSopenharmony_ci * @namespace vibrator
3461847f8eSopenharmony_ci * @syscap SystemCapability.Sensors.MiscDevice
3561847f8eSopenharmony_ci * @atomicservice
3661847f8eSopenharmony_ci * @since 11
3761847f8eSopenharmony_ci */
3861847f8eSopenharmony_cideclare namespace vibrator {
3961847f8eSopenharmony_ci  /**
4061847f8eSopenharmony_ci   * The trigger motor vibrates for a specified length of time.
4161847f8eSopenharmony_ci   *
4261847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
4361847f8eSopenharmony_ci   * @param { number } duration Indicate the duration of the motor vibration.
4461847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback The callback of vibrate.
4561847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
4661847f8eSopenharmony_ci   * @since 8
4761847f8eSopenharmony_ci   * @deprecated since 9
4861847f8eSopenharmony_ci   * @useinstead vibrator#startVibration
4961847f8eSopenharmony_ci   */
5061847f8eSopenharmony_ci  function vibrate(duration: number, callback?: AsyncCallback<void>): void;
5161847f8eSopenharmony_ci
5261847f8eSopenharmony_ci  /**
5361847f8eSopenharmony_ci   * The trigger motor vibrates for a specified length of time.
5461847f8eSopenharmony_ci   *
5561847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
5661847f8eSopenharmony_ci   * @param { number } duration Indicate the duration of the motor vibration.
5761847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return the result.
5861847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
5961847f8eSopenharmony_ci   * @since 8
6061847f8eSopenharmony_ci   * @deprecated since 9
6161847f8eSopenharmony_ci   * @useinstead vibrator#startVibration
6261847f8eSopenharmony_ci   */
6361847f8eSopenharmony_ci  function vibrate(duration: number): Promise<void>;
6461847f8eSopenharmony_ci
6561847f8eSopenharmony_ci  /**
6661847f8eSopenharmony_ci   * The trigger motor vibrates for the specified effect of the preset.
6761847f8eSopenharmony_ci   *
6861847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
6961847f8eSopenharmony_ci   * @param { EffectId } effectId Indicate the specified effect of the preset, {@code EffectId}.
7061847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return the result.
7161847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
7261847f8eSopenharmony_ci   * @since 8
7361847f8eSopenharmony_ci   * @deprecated since 9
7461847f8eSopenharmony_ci   * @useinstead vibrator#startVibration
7561847f8eSopenharmony_ci   */
7661847f8eSopenharmony_ci  function vibrate(effectId: EffectId): Promise<void>;
7761847f8eSopenharmony_ci
7861847f8eSopenharmony_ci  /**
7961847f8eSopenharmony_ci   * The trigger motor vibrates for the specified effect of the preset.
8061847f8eSopenharmony_ci   *
8161847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
8261847f8eSopenharmony_ci   * @param { EffectId } effectId Indicate the specified effect of the preset, {@code EffectId}.
8361847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback The callback of vibrate.
8461847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
8561847f8eSopenharmony_ci   * @since 8
8661847f8eSopenharmony_ci   * @deprecated since 9
8761847f8eSopenharmony_ci   * @useinstead vibrator#startVibration
8861847f8eSopenharmony_ci   */
8961847f8eSopenharmony_ci  function vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void;
9061847f8eSopenharmony_ci
9161847f8eSopenharmony_ci  /**
9261847f8eSopenharmony_ci   * Trigger vibrator vibration.
9361847f8eSopenharmony_ci   *
9461847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
9561847f8eSopenharmony_ci   * @param { VibrateEffect } effect - Indicate vibrate effect, {@code VibrateEffect}.
9661847f8eSopenharmony_ci   * @param { VibrateAttribute } attribute - Indicate vibrate attribute, {@code VibrateAttribute}.
9761847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of startVibration.
9861847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
9961847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
10061847f8eSopenharmony_ci   * <br> 2. Incorrect parameter types; 3. Parameter verification failed.
10161847f8eSopenharmony_ci   * @throws { BusinessError } 801 - Capability not supported.
10261847f8eSopenharmony_ci   * @throws { BusinessError } 14600101 - Device operation failed.
10361847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
10461847f8eSopenharmony_ci   * @since 9
10561847f8eSopenharmony_ci   */
10661847f8eSopenharmony_ci  /**
10761847f8eSopenharmony_ci   * Trigger vibrator vibration.
10861847f8eSopenharmony_ci   *
10961847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
11061847f8eSopenharmony_ci   * @param { VibrateEffect } effect - Indicate vibrate effect, {@code VibrateEffect}
11161847f8eSopenharmony_ci   * @param { VibrateAttribute } attribute - Indicate vibrate attribute, {@code VibrateAttribute}
11261847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of startVibration
11361847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied
11461847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
11561847f8eSopenharmony_ci   * <br> 2. Incorrect parameter types; 3. Parameter verification failed.
11661847f8eSopenharmony_ci   * @throws { BusinessError } 801 - Capability not supported
11761847f8eSopenharmony_ci   * @throws { BusinessError } 14600101 - Device operation failed
11861847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
11961847f8eSopenharmony_ci   * @atomicservice
12061847f8eSopenharmony_ci   * @since 11
12161847f8eSopenharmony_ci   */
12261847f8eSopenharmony_ci  function startVibration(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback<void>): void;
12361847f8eSopenharmony_ci
12461847f8eSopenharmony_ci  /**
12561847f8eSopenharmony_ci   * Trigger vibrator vibration.
12661847f8eSopenharmony_ci   *
12761847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
12861847f8eSopenharmony_ci   * @param { VibrateEffect } effect - Indicate vibrate effect, {@code VibrateEffect}.
12961847f8eSopenharmony_ci   * @param { VibrateAttribute } attribute - Indicate vibrate attribute, {@code VibrateAttribute}.
13061847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return the result.
13161847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
13261847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
13361847f8eSopenharmony_ci   * <br> 2. Incorrect parameter types; 3. Parameter verification failed.
13461847f8eSopenharmony_ci   * @throws { BusinessError } 801 - Capability not supported.
13561847f8eSopenharmony_ci   * @throws { BusinessError } 14600101 - Device operation failed.
13661847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
13761847f8eSopenharmony_ci   * @since 9
13861847f8eSopenharmony_ci   */
13961847f8eSopenharmony_ci  /**
14061847f8eSopenharmony_ci   * Trigger vibrator vibration.
14161847f8eSopenharmony_ci   *
14261847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
14361847f8eSopenharmony_ci   * @param { VibrateEffect } effect - Indicate vibrate effect, {@code VibrateEffect}.
14461847f8eSopenharmony_ci   * @param { VibrateAttribute } attribute - Indicate vibrate attribute, {@code VibrateAttribute}.
14561847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return the result.
14661847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
14761847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
14861847f8eSopenharmony_ci   * <br> 2. Incorrect parameter types; 3. Parameter verification failed.
14961847f8eSopenharmony_ci   * @throws { BusinessError } 801 - Capability not supported.
15061847f8eSopenharmony_ci   * @throws { BusinessError } 14600101 - Device operation failed.
15161847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
15261847f8eSopenharmony_ci   * @atomicservice
15361847f8eSopenharmony_ci   * @since 11
15461847f8eSopenharmony_ci   */
15561847f8eSopenharmony_ci  function startVibration(effect: VibrateEffect, attribute: VibrateAttribute): Promise<void>;
15661847f8eSopenharmony_ci
15761847f8eSopenharmony_ci  /**
15861847f8eSopenharmony_ci   * Stop the vibrator from vibrating.
15961847f8eSopenharmony_ci   *
16061847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
16161847f8eSopenharmony_ci   * @param { VibratorStopMode } stopMode - Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}.
16261847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return the result.
16361847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
16461847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
16561847f8eSopenharmony_ci   * <br> 2. Incorrect parameter types; 3. Parameter verification failed.
16661847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
16761847f8eSopenharmony_ci   * @since 9
16861847f8eSopenharmony_ci   */
16961847f8eSopenharmony_ci  function stopVibration(stopMode: VibratorStopMode): Promise<void>;
17061847f8eSopenharmony_ci
17161847f8eSopenharmony_ci  /**
17261847f8eSopenharmony_ci   * Stop the vibrator from vibrating.
17361847f8eSopenharmony_ci   *
17461847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
17561847f8eSopenharmony_ci   * @param { VibratorStopMode } stopMode - Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}.
17661847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of stopVibration.
17761847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
17861847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
17961847f8eSopenharmony_ci   * <br> 2. Incorrect parameter types; 3. Parameter verification failed.
18061847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
18161847f8eSopenharmony_ci   * @since 9
18261847f8eSopenharmony_ci   */
18361847f8eSopenharmony_ci  function stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback<void>): void;
18461847f8eSopenharmony_ci
18561847f8eSopenharmony_ci  /**
18661847f8eSopenharmony_ci   * Stop any type of vibration.
18761847f8eSopenharmony_ci   *
18861847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
18961847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of stopVibration.
19061847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
19161847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
19261847f8eSopenharmony_ci   * @since 10
19361847f8eSopenharmony_ci   */
19461847f8eSopenharmony_ci  /**
19561847f8eSopenharmony_ci   * Stop any type of vibration.
19661847f8eSopenharmony_ci   *
19761847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
19861847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of stopVibration.
19961847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
20061847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
20161847f8eSopenharmony_ci   * @atomicservice
20261847f8eSopenharmony_ci   * @since 11
20361847f8eSopenharmony_ci   */
20461847f8eSopenharmony_ci  function stopVibration(callback: AsyncCallback<void>): void;
20561847f8eSopenharmony_ci
20661847f8eSopenharmony_ci  /**
20761847f8eSopenharmony_ci   * Stop any type of vibration.
20861847f8eSopenharmony_ci   *
20961847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
21061847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return the result.
21161847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
21261847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
21361847f8eSopenharmony_ci   * @since 10
21461847f8eSopenharmony_ci   */
21561847f8eSopenharmony_ci  /**
21661847f8eSopenharmony_ci   * Stop any type of vibration.
21761847f8eSopenharmony_ci   *
21861847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
21961847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return the result.
22061847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
22161847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
22261847f8eSopenharmony_ci   * @atomicservice
22361847f8eSopenharmony_ci   * @since 11
22461847f8eSopenharmony_ci   */
22561847f8eSopenharmony_ci  function stopVibration(): Promise<void>;
22661847f8eSopenharmony_ci
22761847f8eSopenharmony_ci  /**
22861847f8eSopenharmony_ci   * Stop any type of vibration.
22961847f8eSopenharmony_ci   *
23061847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
23161847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
23261847f8eSopenharmony_ci   * @throws { BusinessError } 14600101 - Device operation failed.
23361847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
23461847f8eSopenharmony_ci   * @atomicservice
23561847f8eSopenharmony_ci   * @since 12
23661847f8eSopenharmony_ci   */
23761847f8eSopenharmony_ci  function stopVibrationSync(): void;
23861847f8eSopenharmony_ci
23961847f8eSopenharmony_ci  /**
24061847f8eSopenharmony_ci   * Whether the preset vibration effect is supported.
24161847f8eSopenharmony_ci   *
24261847f8eSopenharmony_ci   * @param { string } effectId Indicate the specified effect of the preset, {@code EffectId}.
24361847f8eSopenharmony_ci   * @param { AsyncCallback<boolean> } callback The callback of isSupportEffect.
24461847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
24561847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
24661847f8eSopenharmony_ci   * <br> 2. Incorrect parameter types; 3. Parameter verification failed.
24761847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
24861847f8eSopenharmony_ci   * @since 10
24961847f8eSopenharmony_ci   */
25061847f8eSopenharmony_ci  function isSupportEffect(effectId: string, callback: AsyncCallback<boolean>): void;
25161847f8eSopenharmony_ci
25261847f8eSopenharmony_ci  /**
25361847f8eSopenharmony_ci   * Whether the preset vibration effect is supported.
25461847f8eSopenharmony_ci   *
25561847f8eSopenharmony_ci   * @param { string } effectId Indicate the specified effect of the preset, {@code EffectId}.
25661847f8eSopenharmony_ci   * @returns { Promise<boolean> } Promise used to return the result.
25761847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
25861847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
25961847f8eSopenharmony_ci   * <br> 2. Incorrect parameter types; 3. Parameter verification failed.
26061847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
26161847f8eSopenharmony_ci   * @since 10
26261847f8eSopenharmony_ci   */
26361847f8eSopenharmony_ci  function isSupportEffect(effectId: string): Promise<boolean>;
26461847f8eSopenharmony_ci
26561847f8eSopenharmony_ci  /**
26661847f8eSopenharmony_ci   * Whether the preset vibration effect is supported.
26761847f8eSopenharmony_ci   *
26861847f8eSopenharmony_ci   * @param { string } effectId Indicate the specified effect of the preset, {@code EffectId}.
26961847f8eSopenharmony_ci   * @returns { boolean } Returns whether the effect is supported.
27061847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
27161847f8eSopenharmony_ci   * <br> 2. Incorrect parameter types; 3. Parameter verification failed.
27261847f8eSopenharmony_ci   * @throws { BusinessError } 14600101 - Device operation failed.
27361847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
27461847f8eSopenharmony_ci   * @since 12
27561847f8eSopenharmony_ci   */
27661847f8eSopenharmony_ci  function isSupportEffectSync(effectId: string): boolean;
27761847f8eSopenharmony_ci
27861847f8eSopenharmony_ci  /**
27961847f8eSopenharmony_ci   * Stop the motor from vibrating.
28061847f8eSopenharmony_ci   *
28161847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
28261847f8eSopenharmony_ci   * @param { VibratorStopMode } stopMode Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}.
28361847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return the result.
28461847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
28561847f8eSopenharmony_ci   * @since 8
28661847f8eSopenharmony_ci   * @deprecated since 9
28761847f8eSopenharmony_ci   * @useinstead vibrator#stopVibration
28861847f8eSopenharmony_ci   */
28961847f8eSopenharmony_ci  function stop(stopMode: VibratorStopMode): Promise<void>;
29061847f8eSopenharmony_ci
29161847f8eSopenharmony_ci  /**
29261847f8eSopenharmony_ci   * Stop the motor from vibrating.
29361847f8eSopenharmony_ci   *
29461847f8eSopenharmony_ci   * @permission ohos.permission.VIBRATE
29561847f8eSopenharmony_ci   * @param { VibratorStopMode } stopMode Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}.
29661847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback The callback of stop.
29761847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
29861847f8eSopenharmony_ci   * @since 8
29961847f8eSopenharmony_ci   * @deprecated since 9
30061847f8eSopenharmony_ci   * @useinstead vibrator#stopVibration
30161847f8eSopenharmony_ci   */
30261847f8eSopenharmony_ci  function stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void;
30361847f8eSopenharmony_ci
30461847f8eSopenharmony_ci  /**
30561847f8eSopenharmony_ci   * Whether the high-definition haptic is supported.
30661847f8eSopenharmony_ci   *
30761847f8eSopenharmony_ci   * @returns { boolean } Returns whether the high-definition haptic is supported.
30861847f8eSopenharmony_ci   * @throws { BusinessError } 14600101 - Device operation failed.
30961847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
31061847f8eSopenharmony_ci   * @since 12
31161847f8eSopenharmony_ci   */
31261847f8eSopenharmony_ci  function isHdHapticSupported(): boolean;
31361847f8eSopenharmony_ci
31461847f8eSopenharmony_ci  /**
31561847f8eSopenharmony_ci   * Preset vibration effect string.
31661847f8eSopenharmony_ci   * 
31761847f8eSopenharmony_ci   * @enum { string }
31861847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
31961847f8eSopenharmony_ci   * @since 8
32061847f8eSopenharmony_ci   */
32161847f8eSopenharmony_ci  enum EffectId {
32261847f8eSopenharmony_ci  /**
32361847f8eSopenharmony_ci   * Describes the vibration effect of the vibrator when a user adjusts the timer.
32461847f8eSopenharmony_ci   *
32561847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
32661847f8eSopenharmony_ci   * @since 8
32761847f8eSopenharmony_ci   */
32861847f8eSopenharmony_ci    EFFECT_CLOCK_TIMER = 'haptic.clock.timer'
32961847f8eSopenharmony_ci  }
33061847f8eSopenharmony_ci
33161847f8eSopenharmony_ci  /**
33261847f8eSopenharmony_ci   * Simple and universal vibration effects.
33361847f8eSopenharmony_ci   * 
33461847f8eSopenharmony_ci   * @enum { string }
33561847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
33661847f8eSopenharmony_ci   * @since 12
33761847f8eSopenharmony_ci   */
33861847f8eSopenharmony_ci  enum HapticFeedback {
33961847f8eSopenharmony_ci    /**
34061847f8eSopenharmony_ci     * Describes the soft vibration effect of the vibrator.
34161847f8eSopenharmony_ci     *
34261847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
34361847f8eSopenharmony_ci     * @since 12
34461847f8eSopenharmony_ci     */
34561847f8eSopenharmony_ci    EFFECT_SOFT = 'haptic.effect.soft',
34661847f8eSopenharmony_ci
34761847f8eSopenharmony_ci    /**
34861847f8eSopenharmony_ci     * Describes the hard vibration effect of the vibrator.
34961847f8eSopenharmony_ci     *
35061847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
35161847f8eSopenharmony_ci     * @since 12
35261847f8eSopenharmony_ci     */
35361847f8eSopenharmony_ci    EFFECT_HARD = 'haptic.effect.hard',
35461847f8eSopenharmony_ci
35561847f8eSopenharmony_ci    /**
35661847f8eSopenharmony_ci     * Describes the sharp vibration effect of the vibrator.
35761847f8eSopenharmony_ci     *
35861847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
35961847f8eSopenharmony_ci     * @since 12
36061847f8eSopenharmony_ci     */
36161847f8eSopenharmony_ci    EFFECT_SHARP = 'haptic.effect.sharp'
36261847f8eSopenharmony_ci  }
36361847f8eSopenharmony_ci
36461847f8eSopenharmony_ci  /**
36561847f8eSopenharmony_ci   * Vibrator vibration stop mode.
36661847f8eSopenharmony_ci   *
36761847f8eSopenharmony_ci   * @enum { string }
36861847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
36961847f8eSopenharmony_ci   * @since 8
37061847f8eSopenharmony_ci   */
37161847f8eSopenharmony_ci  enum VibratorStopMode {
37261847f8eSopenharmony_ci  /**
37361847f8eSopenharmony_ci   * Indicates the mode of stopping a one-shot vibration effect.
37461847f8eSopenharmony_ci   *
37561847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
37661847f8eSopenharmony_ci   * @since 8
37761847f8eSopenharmony_ci   */
37861847f8eSopenharmony_ci    VIBRATOR_STOP_MODE_TIME = 'time',
37961847f8eSopenharmony_ci
38061847f8eSopenharmony_ci  /**
38161847f8eSopenharmony_ci   * Indicates the mode of stopping a preset vibration effect.
38261847f8eSopenharmony_ci   *
38361847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
38461847f8eSopenharmony_ci   * @since 8
38561847f8eSopenharmony_ci   */
38661847f8eSopenharmony_ci    VIBRATOR_STOP_MODE_PRESET = 'preset'
38761847f8eSopenharmony_ci  }
38861847f8eSopenharmony_ci
38961847f8eSopenharmony_ci  /**
39061847f8eSopenharmony_ci   * The use of vibration.
39161847f8eSopenharmony_ci   *
39261847f8eSopenharmony_ci   * @typedef {'unknown' | 'alarm' | 'ring' | 'notification' | 'communication' |
39361847f8eSopenharmony_ci   * 'touch' | 'media' | 'physicalFeedback' | 'simulateReality'}
39461847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
39561847f8eSopenharmony_ci   * @since 9
39661847f8eSopenharmony_ci   */
39761847f8eSopenharmony_ci  /**
39861847f8eSopenharmony_ci   * The use of vibration.
39961847f8eSopenharmony_ci   *
40061847f8eSopenharmony_ci   * @typedef {'unknown' | 'alarm' | 'ring' | 'notification' | 'communication' |
40161847f8eSopenharmony_ci   * 'touch' | 'media' | 'physicalFeedback' | 'simulateReality'}
40261847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
40361847f8eSopenharmony_ci   * @atomicservice
40461847f8eSopenharmony_ci   * @since 11
40561847f8eSopenharmony_ci   */
40661847f8eSopenharmony_ci  type Usage = 'unknown' | 'alarm' | 'ring' | 'notification' | 'communication' |
40761847f8eSopenharmony_ci  'touch' | 'media' | 'physicalFeedback' | 'simulateReality';
40861847f8eSopenharmony_ci
40961847f8eSopenharmony_ci  /**
41061847f8eSopenharmony_ci   * The attribute of vibration.
41161847f8eSopenharmony_ci   *
41261847f8eSopenharmony_ci   * @interface VibrateAttribute
41361847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
41461847f8eSopenharmony_ci   * @since 9
41561847f8eSopenharmony_ci   */
41661847f8eSopenharmony_ci  /**
41761847f8eSopenharmony_ci   * The attribute of vibration.
41861847f8eSopenharmony_ci   *
41961847f8eSopenharmony_ci   * @interface VibrateAttribute
42061847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
42161847f8eSopenharmony_ci   * @atomicservice
42261847f8eSopenharmony_ci   * @since 11
42361847f8eSopenharmony_ci   */
42461847f8eSopenharmony_ci  interface VibrateAttribute {
42561847f8eSopenharmony_ci  /**
42661847f8eSopenharmony_ci   * Vibrator id, default is 0.
42761847f8eSopenharmony_ci   *
42861847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
42961847f8eSopenharmony_ci   * @since 9
43061847f8eSopenharmony_ci   */
43161847f8eSopenharmony_ci  /**
43261847f8eSopenharmony_ci   * Vibrator id, default is 0.
43361847f8eSopenharmony_ci   *
43461847f8eSopenharmony_ci   * @type { ?number }
43561847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
43661847f8eSopenharmony_ci   * @atomicservice
43761847f8eSopenharmony_ci   * @since 11
43861847f8eSopenharmony_ci   */
43961847f8eSopenharmony_ci    id?: number;
44061847f8eSopenharmony_ci
44161847f8eSopenharmony_ci  /**
44261847f8eSopenharmony_ci   * The use of vibration.
44361847f8eSopenharmony_ci   *
44461847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
44561847f8eSopenharmony_ci   * @since 9
44661847f8eSopenharmony_ci   */
44761847f8eSopenharmony_ci  /**
44861847f8eSopenharmony_ci   * The use of vibration.
44961847f8eSopenharmony_ci   *
45061847f8eSopenharmony_ci   * @type { Usage }
45161847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
45261847f8eSopenharmony_ci   * @atomicservice
45361847f8eSopenharmony_ci   * @since 11
45461847f8eSopenharmony_ci   */
45561847f8eSopenharmony_ci    usage: Usage;
45661847f8eSopenharmony_ci
45761847f8eSopenharmony_ci  /**
45861847f8eSopenharmony_ci   * Indicates whether to bypass system management switches.
45961847f8eSopenharmony_ci   *
46061847f8eSopenharmony_ci   * @type { ?boolean }
46161847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
46261847f8eSopenharmony_ci   * @systemapi
46361847f8eSopenharmony_ci   * @since 12
46461847f8eSopenharmony_ci   */
46561847f8eSopenharmony_ci    systemUsage?: boolean;
46661847f8eSopenharmony_ci  }
46761847f8eSopenharmony_ci
46861847f8eSopenharmony_ci  /**
46961847f8eSopenharmony_ci   * Describes the effect of vibration.
47061847f8eSopenharmony_ci   *
47161847f8eSopenharmony_ci   * @typedef { VibrateTime | VibratePreset }
47261847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
47361847f8eSopenharmony_ci   * @since 9
47461847f8eSopenharmony_ci   */
47561847f8eSopenharmony_ci  /**
47661847f8eSopenharmony_ci   * Describes the effect of vibration.
47761847f8eSopenharmony_ci   *
47861847f8eSopenharmony_ci   * @typedef { VibrateTime | VibratePreset | VibrateFromFile }
47961847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
48061847f8eSopenharmony_ci   * @since 10
48161847f8eSopenharmony_ci   */
48261847f8eSopenharmony_ci  /**
48361847f8eSopenharmony_ci   * Describes the effect of vibration.
48461847f8eSopenharmony_ci   *
48561847f8eSopenharmony_ci   * @typedef { VibrateTime | VibratePreset | VibrateFromFile }
48661847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
48761847f8eSopenharmony_ci   * @atomicservice
48861847f8eSopenharmony_ci   * @since 11
48961847f8eSopenharmony_ci   */
49061847f8eSopenharmony_ci  type VibrateEffect = VibrateTime | VibratePreset | VibrateFromFile;
49161847f8eSopenharmony_ci
49261847f8eSopenharmony_ci  /**
49361847f8eSopenharmony_ci   * Vibrate continuously for a period of time at the default intensity of the system.
49461847f8eSopenharmony_ci   *
49561847f8eSopenharmony_ci   * @interface VibrateTime
49661847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
49761847f8eSopenharmony_ci   * @since 9
49861847f8eSopenharmony_ci   */
49961847f8eSopenharmony_ci  /**
50061847f8eSopenharmony_ci   * Vibrate continuously for a period of time at the default intensity of the system.
50161847f8eSopenharmony_ci   *
50261847f8eSopenharmony_ci   * @interface VibrateTime
50361847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
50461847f8eSopenharmony_ci   * @atomicservice
50561847f8eSopenharmony_ci   * @since 11
50661847f8eSopenharmony_ci   */
50761847f8eSopenharmony_ci  interface VibrateTime {
50861847f8eSopenharmony_ci    /**
50961847f8eSopenharmony_ci     * The value is "time", which triggers the motor vibration according to the specified duration.
51061847f8eSopenharmony_ci     *
51161847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
51261847f8eSopenharmony_ci     * @since 9
51361847f8eSopenharmony_ci     */
51461847f8eSopenharmony_ci    /**
51561847f8eSopenharmony_ci     * The value is "time", which triggers the motor vibration according to the specified duration.
51661847f8eSopenharmony_ci     *
51761847f8eSopenharmony_ci     * @type { 'time' }
51861847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
51961847f8eSopenharmony_ci     * @atomicservice
52061847f8eSopenharmony_ci     * @since 11
52161847f8eSopenharmony_ci     */
52261847f8eSopenharmony_ci    type: 'time';
52361847f8eSopenharmony_ci
52461847f8eSopenharmony_ci    /**
52561847f8eSopenharmony_ci     * The duration of the vibration, in ms.
52661847f8eSopenharmony_ci     *
52761847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
52861847f8eSopenharmony_ci     * @since 9
52961847f8eSopenharmony_ci     */
53061847f8eSopenharmony_ci    /**
53161847f8eSopenharmony_ci     * The duration of the vibration, in ms.
53261847f8eSopenharmony_ci     *
53361847f8eSopenharmony_ci     * @type { number }
53461847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
53561847f8eSopenharmony_ci     * @atomicservice
53661847f8eSopenharmony_ci     * @since 11
53761847f8eSopenharmony_ci     */
53861847f8eSopenharmony_ci    duration: number; /** The duration of the vibration, in ms */
53961847f8eSopenharmony_ci  }
54061847f8eSopenharmony_ci
54161847f8eSopenharmony_ci  /**
54261847f8eSopenharmony_ci   * Preset vibration type vibration effect.
54361847f8eSopenharmony_ci   *
54461847f8eSopenharmony_ci   * @interface VibratePreset
54561847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
54661847f8eSopenharmony_ci   * @since 9
54761847f8eSopenharmony_ci   */
54861847f8eSopenharmony_ci  interface VibratePreset {
54961847f8eSopenharmony_ci    /**
55061847f8eSopenharmony_ci     * The value is "preset", which triggers motor vibration according to preset vibration effect.
55161847f8eSopenharmony_ci     *
55261847f8eSopenharmony_ci     * @type { 'preset' }
55361847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
55461847f8eSopenharmony_ci     * @since 9
55561847f8eSopenharmony_ci     */
55661847f8eSopenharmony_ci    type: 'preset';
55761847f8eSopenharmony_ci
55861847f8eSopenharmony_ci    /**
55961847f8eSopenharmony_ci     * Preset type vibration.
56061847f8eSopenharmony_ci     *
56161847f8eSopenharmony_ci     * @type { string }
56261847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
56361847f8eSopenharmony_ci     * @since 9
56461847f8eSopenharmony_ci     */
56561847f8eSopenharmony_ci    effectId: string;
56661847f8eSopenharmony_ci
56761847f8eSopenharmony_ci    /**
56861847f8eSopenharmony_ci     * The number of vibration repetitions.
56961847f8eSopenharmony_ci     *
57061847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
57161847f8eSopenharmony_ci     * @since 9
57261847f8eSopenharmony_ci     */
57361847f8eSopenharmony_ci    /**
57461847f8eSopenharmony_ci     * The number of vibration repetitions.
57561847f8eSopenharmony_ci     *
57661847f8eSopenharmony_ci     * @type { ?number }
57761847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
57861847f8eSopenharmony_ci     * @since 12
57961847f8eSopenharmony_ci     */
58061847f8eSopenharmony_ci    count?: number;
58161847f8eSopenharmony_ci
58261847f8eSopenharmony_ci    /**
58361847f8eSopenharmony_ci     * The intensity of vibration effect.
58461847f8eSopenharmony_ci     *
58561847f8eSopenharmony_ci     * @type { ?number }
58661847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
58761847f8eSopenharmony_ci     * @since 12
58861847f8eSopenharmony_ci     */
58961847f8eSopenharmony_ci    intensity?: number;
59061847f8eSopenharmony_ci  }
59161847f8eSopenharmony_ci
59261847f8eSopenharmony_ci  /**
59361847f8eSopenharmony_ci   * Custom vibration, vibrate the effect from a haptic file.
59461847f8eSopenharmony_ci   *
59561847f8eSopenharmony_ci   * @interface VibrateFromFile
59661847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
59761847f8eSopenharmony_ci   * @since 10
59861847f8eSopenharmony_ci   */
59961847f8eSopenharmony_ci  interface VibrateFromFile {
60061847f8eSopenharmony_ci  /**
60161847f8eSopenharmony_ci   * The value is "file", which triggers motor vibration according to the vibration profile.
60261847f8eSopenharmony_ci   *
60361847f8eSopenharmony_ci   * @type { 'file' }
60461847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
60561847f8eSopenharmony_ci   * @since 10
60661847f8eSopenharmony_ci   */
60761847f8eSopenharmony_ci    type: 'file';
60861847f8eSopenharmony_ci
60961847f8eSopenharmony_ci  /**
61061847f8eSopenharmony_ci   * Haptic file descriptor, some formats are supported.
61161847f8eSopenharmony_ci   *
61261847f8eSopenharmony_ci   * @type { HapticFileDescriptor }
61361847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
61461847f8eSopenharmony_ci   * @since 10
61561847f8eSopenharmony_ci   */
61661847f8eSopenharmony_ci    hapticFd: HapticFileDescriptor;
61761847f8eSopenharmony_ci  }
61861847f8eSopenharmony_ci
61961847f8eSopenharmony_ci  /**
62061847f8eSopenharmony_ci   * Haptic file descriptor. The caller needs to ensure that the fd is valid and
62161847f8eSopenharmony_ci   * the offset and length are correct.
62261847f8eSopenharmony_ci   *
62361847f8eSopenharmony_ci   * @interface HapticFileDescriptor
62461847f8eSopenharmony_ci   * @syscap SystemCapability.Sensors.MiscDevice
62561847f8eSopenharmony_ci   * @since 10
62661847f8eSopenharmony_ci   */
62761847f8eSopenharmony_ci  interface HapticFileDescriptor {
62861847f8eSopenharmony_ci    /**
62961847f8eSopenharmony_ci     * The file descriptor of haptic effect source from file system. The caller
63061847f8eSopenharmony_ci     * is responsible to close the file descriptor.
63161847f8eSopenharmony_ci     *
63261847f8eSopenharmony_ci     * @type { number }
63361847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
63461847f8eSopenharmony_ci     * @since 10
63561847f8eSopenharmony_ci     */
63661847f8eSopenharmony_ci    fd: number;
63761847f8eSopenharmony_ci
63861847f8eSopenharmony_ci    /**
63961847f8eSopenharmony_ci     * The offset into the file where the data to be read, in bytes. By default,
64061847f8eSopenharmony_ci     * the offset is zero.
64161847f8eSopenharmony_ci     *
64261847f8eSopenharmony_ci     * @type { ?number }
64361847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
64461847f8eSopenharmony_ci     * @since 10
64561847f8eSopenharmony_ci     */
64661847f8eSopenharmony_ci    offset?: number;
64761847f8eSopenharmony_ci
64861847f8eSopenharmony_ci    /**
64961847f8eSopenharmony_ci     * The length in bytes of the data to be read. By default, the length is the
65061847f8eSopenharmony_ci     * rest of bytes in the file from the offset.
65161847f8eSopenharmony_ci     *
65261847f8eSopenharmony_ci     * @type { ?number }
65361847f8eSopenharmony_ci     * @syscap SystemCapability.Sensors.MiscDevice
65461847f8eSopenharmony_ci     * @since 10
65561847f8eSopenharmony_ci     */
65661847f8eSopenharmony_ci    length?: number;
65761847f8eSopenharmony_ci  }
65861847f8eSopenharmony_ci}
65961847f8eSopenharmony_ci
66061847f8eSopenharmony_ciexport default vibrator;
661