From: luozheng <1732036298@qq.com> Date: Tue, 3 Dec 2024 09:50:51 +0000 (+0800) Subject: 将主界面进入applist界面Power键触发由释放事件改为按下事件,1.加快界面进入速度;2,解决手表息屏状态下(主界面)按Power键概率性会进入applist界面... X-Git-Tag: v1.3.113-repair_tp~143^2~31 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=42b9fd4f07980414656a296fb7f3b757462b3cf3;p=mirrors%2FFD230.git 将主界面进入applist界面Power键触发由释放事件改为按下事件,1.加快界面进入速度;2,解决手表息屏状态下(主界面)按Power键概率性会进入applist界面(需要多台手表验证) --- 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: