int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView();
int screenState = uapi_get_screen_state();
- int originalScreenState = screenState; // 保存原始屏幕状态,用于HandlePowerKey判断
+ int originalScreenState = screenState; // 保存原始屏幕状态,用于判断是否息屏
// 按键事件日志
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnKeyAct: keyID=%d, keyState=%d, screenState=%d", keyID, keyState, screenState);
- // 刷新息屏计时:任意按键按下时重置屏幕熄灭倒计时
- if (keyState == InputDevice::STATE_PRESS) {
+ // 息屏后,只有电源键操作有效,其他操作都直接忽略
+ bool isPowerKey = (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER));
+ if (originalScreenState != 0 && !isPowerKey) {
+ // 息屏状态且不是电源键,直接忽略
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnKeyAct: screen is off and key is not power key, ignore keyID=%d", keyID);
+ return true;
+ }
+
+ // 刷新息屏计时:任意按键按下时重置屏幕熄灭倒计时(只有电源键或已亮屏时才刷新)
+ if (keyState == InputDevice::STATE_PRESS && (isPowerKey || originalScreenState == 0)) {
uapi_set_screen_on_api();
// 修复:在调用uapi_set_screen_on_api()后重新获取屏幕状态,确保使用最新的状态
screenState = uapi_get_screen_state();
return HandlePowerKey(keyState, currentView, currentSubView, originalScreenState);
case static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_FUNC):
- // 非电源键需要亮屏才能处理
+ // 非电源键需要亮屏才能处理(已在上面检查过,这里确保亮屏)
if (screenState != 0) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleFuncKey: screen is off, ignore");
return true;
return HandleFuncKey(keyState, currentView, currentSubView, screenState);
case static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_VENDOR_UP):
- // 非电源键需要亮屏才能处理
+ // 非电源键需要亮屏才能处理(已在上面检查过,这里确保亮屏)
if (screenState != 0) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleVendorUpKey: screen is off, ignore");
return true;
return HandleVendorUpKey(keyState, currentView, currentSubView, screenState);
case static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_VENDOR_DOWN):
- // 非电源键需要亮屏才能处理
+ // 非电源键需要亮屏才能处理(已在上面检查过,这里确保亮屏)
if (screenState != 0) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleVendorDownKey: screen is off, ignore");
return true;
#ifdef CUSTOM_UTILS
if(custom_get_factory_test_flag())
return;
-#endif
+#endif
+ // 检查是否需要等待音频初始化完成后跳转界面
+ if (pendingDialogueJump && ln_ws_is_audio_initialized()) {
+ pendingDialogueJump = false;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "音频初始化完成,执行延迟的界面跳转");
+
+ int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
+
+ if(currentView == THUNDERBIRD_GUIDEVIEW)
+ {
+ ThunderBirdDialogueView::GetInstance()->Isband(false);
+ }
+ else
+ {
+ ThunderBirdDialogueView::GetInstance()->Isband(true);
+ }
+ }
+
//如果在二维码界面 判断是否绑定
if(ThunderBirdMainView::GetInstance() != nullptr)
{
static void HandleFuncKeyLongPressCallBack(void)
{
+ // 息屏后,长按FUNC键也应该被忽略
+ int screenState = uapi_get_screen_state();
+ if (screenState != 0) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleFuncKeyLongPressCallBack: screen is off, ignore");
+ return;
+ }
+
if (ThunderBirdPresenter::GetInstance()) {
ThunderBirdPresenter::GetInstance()->HandleFuncKeyLongPress();
}
}
}
- ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
- if(currentView == THUNDERBIRD_GUIDEVIEW)
+ // 检查音频是否已初始化,如果未初始化则设置标志位等待定时器检查
+ if(ln_ws_is_audio_initialized())
{
- ThunderBirdDialogueView::GetInstance()->Isband(false);
+ // 音频已初始化,直接跳转界面
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
+ if(currentView == THUNDERBIRD_GUIDEVIEW)
+ {
+ ThunderBirdDialogueView::GetInstance()->Isband(false);
+ }
+ else
+ {
+ ThunderBirdDialogueView::GetInstance()->Isband(true);
+ }
}
else
{
- ThunderBirdDialogueView::GetInstance()->Isband(true);
+ // 音频未初始化,设置标志位,等待定时器检查
+ pendingDialogueJump = true;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "音频未初始化,设置pendingDialogueJump=true,等待定时器检查");
}
+
isDialogueing = true;
ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 打开屏幕常亮
// 进入对话模式时记录当前表情