From 0f0c9a9d9479fd87c9643a0fa1fdbcdba2fabea4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Tue, 3 Dec 2024 09:55:45 +0000 Subject: [PATCH] Merge #1490 into sdk602patch0911 from refs/changes/1490/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 将主界面进入applist界面Power键触发由释放事件改为按下事件,1.加快界面进入速度;2,解决手表息屏状态下(主界面)按Power键概率性会进入applist界面(需要多台手表验证) * refs/changes/1490/head: (1 commits squashed) - 将主界面进入applist界面Power键触发由释放事件改为按下事件,1.加快界面进入速度;2,解决手表息屏状态下(主界面)按Power键概率性会进入applist界面(需要多台手表验证) Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: Caisking <3449750381@qq.com> Reviewed-by: 罗正 <1732036298@qq.com> Reviewed-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Reviewed-by: aliyun6865282430 <1624952103@qq.com> Merged-by: Caisking <3449750381@qq.com> CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1490 --- .../nativeui/key/include/KeyInputListener.h | 2 +- .../nativeui/key/src/KeyInputListener.cpp | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/key/include/KeyInputListener.h b/code/sdk/application/wearable/fd230app/nativeui/key/include/KeyInputListener.h index 9d3eb281c..d9338e69c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/key/include/KeyInputListener.h +++ b/code/sdk/application/wearable/fd230app/nativeui/key/include/KeyInputListener.h @@ -24,7 +24,7 @@ namespace OHOS bool OnKeyAct(UIView &view, const KeyEvent &event) override; private: - void OnKeyPress(void); + void OnKeyPress(const KeyEvent &event); void OnKeyLongPress(const KeyEvent &event); void OnKeyRelease(const KeyEvent &event); void CallVolumeDipSwitchControl(VolumeChangeStatus status); diff --git a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp index be019477e..2defe02da 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp @@ -53,10 +53,27 @@ namespace OHOS } } - void KeyInputListener::OnKeyPress() + void KeyInputListener::OnKeyPress(const KeyEvent &event) { pressFlag = 1; // 短按标志 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnKeyPress: pressFlag = %d", pressFlag); + uint16 keyID = event.GetKeyId(); + uint16_t currentViewId = NativeAbility::GetInstance().GetCurSliceId(); + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) + { + if (longPressFlag == 0 && pressFlag == 1) + { + HandlePowerKeyPress(currentViewId); + } + } + else if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC)) + { + if (longPressFlag == 0 && pressFlag == 1) + { + HandleFuncKeyPress(currentViewId); + } + } + return; } void KeyInputListener::OnKeyLongPress(const KeyEvent &event) @@ -120,7 +137,7 @@ namespace OHOS uint16 keyID = event.GetKeyId(); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnKeyRelease: keyID = %d, currentViewId = %d, longPressFlag = %d, pressFlag = %d", keyID, currentViewId, longPressFlag, pressFlag); - + #if 0 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { if (longPressFlag == 0 && pressFlag == 1) @@ -135,6 +152,7 @@ namespace OHOS HandleFuncKeyPress(currentViewId); } } + #endif // 重置标志 pressFlag = 0; @@ -216,7 +234,7 @@ namespace OHOS switch (state) { case InputDevice::STATE_PRESS: - OnKeyPress(); + OnKeyPress(event); break; #ifdef __LITEOS_M__ case InputDevice::STATE_LONG_PRESS: -- 2.17.1