diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets index e2ff4f357a38f835c002b785a7ab9d3464639792..615dac78fbc63252a13e2b485dde37c9ffdacbac 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets @@ -119,17 +119,12 @@ export default class PlatformChannel { HapticFeedbackType.HEAVY_IMPACT, HapticFeedbackType.SELECTION_CLICK ]; - for (let i = 0; i < feedbackTypes.length; i++) { - let feedbackType: string = feedbackTypes[i]; - if ( - (HapticFeedbackType[feedbackType] == encodedName) || - (HapticFeedbackType[feedbackType] == null && encodedName == null) - ) { - return HapticFeedbackType[feedbackType]; - } + if (feedbackTypes.includes(encodedName as HapticFeedbackType)) { + return encodedName as HapticFeedbackType; + } else { + Log.e(PlatformChannel.TAG, "No such HapticFeedbackType:" + encodedName); + return HapticFeedbackType.STANDARD; } - Log.e(PlatformChannel.TAG, "No such HapticFeedbackType:" + encodedName); - return HapticFeedbackType.STANDARD; } getClipboardContentFormatFromValue(encodedName: string): ClipboardContentFormat { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets index 2fa7cbf589dda9215418d61b16c75bc921736233..8c757c2a47ed5ef253920e1fb88f15e0f332a5c9 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets @@ -107,24 +107,24 @@ class PlatformPluginCallback implements PlatformMessageHandler { vibrateHapticFeedback(feedbackType: HapticFeedbackType) { switch (feedbackType) { case HapticFeedbackType.STANDARD: - vibrator.startVibration({ type: 'time', duration: 100 }, + vibrator.startVibration({ type: 'time', duration: 75 }, { id: 0, usage: 'touch' }); break; case HapticFeedbackType.LIGHT_IMPACT: - vibrator.startVibration({ type: 'time', duration: 100 }, - { id: 0, usage: 'notification' }).then(); + vibrator.startVibration({ type: 'time', duration: 25 }, + { id: 0, usage: 'touch' }); break; case HapticFeedbackType.MEDIUM_IMPACT: - vibrator.startVibration({ type: 'time', duration: 100 }, - { id: 0, usage: 'ring' }); + vibrator.startVibration({ type: 'time', duration: 150 }, + { id: 0, usage: 'touch' }); break; case HapticFeedbackType.HEAVY_IMPACT: - vibrator.startVibration({ type: 'time', duration: 100 }, - { id: 0, usage: 'alarm' }); + vibrator.startVibration({ type: 'time', duration: 300 }, + { id: 0, usage: 'touch' }); break; case HapticFeedbackType.SELECTION_CLICK: vibrator.startVibration({ type: 'time', duration: 100 }, - { id: 0, usage: 'physicalFeedback' }); + { id: 0, usage: 'touch' }); break; } }