From: aliyun3243248791 Date: Thu, 23 Oct 2025 08:41:01 +0000 (+0000) Subject: Merge #2586 into sdk650pathc0423 from refs/changes/2586/head X-Git-Tag: V1.0.9_20251128_194606_LN~180^2~4^2 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=9175e70fd6c0793b0da5c9a99ebb80bc45073e5b;p=mirrors%2FFD230.git Merge #2586 into sdk650pathc0423 from refs/changes/2586/head Code review from aliyun3243248791 * refs/changes/2586/head: (5 commits squashed) - 增加特殊发型的映射 - 增加解绑提示 - 增加按键息屏 - 优化息屏操作 - Merge branch 'sdk650pathc0423' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk650pathc0423 Signed-off-by: 薛文强 Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/2586 --- diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdAdjustView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdAdjustView.h index 9a1062d68..70bc05263 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdAdjustView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdAdjustView.h @@ -92,6 +92,7 @@ namespace OHOS void ClearAll(void); void Show(int16_t showView); void UpdateTaskReminderText(const char* text); + void ShowUnbindWarning(); enum : int16_t { THUNDERBIRD_ADJUSTVIEW_BIND_SUCCESS = 0, // 绑定成功 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h index 8456fdefa..b809a4374 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h @@ -20,6 +20,7 @@ namespace OHOS void ClearAll(void); void Show(int16_t showView); void UpdateQrcode(); + void UpdateTextLabel(const char* text); enum : int16_t { THUNDERBIRD_GUIDEVIEW_1 = 0, diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h index aa5d4f07e..06b56f697 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h @@ -36,6 +36,7 @@ namespace OHOS void timer_callback_toui_proc(); bool isDialogueing{false};//是否进入对话模式 + bool powerKeyPressed{false};//电源键按下标志位,防止重复触发 // FUNC键长按功能 void RegisterFuncKeyLongPressEvent(void); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdAdjustView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdAdjustView.cpp index ce4f6aeee..421442e92 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdAdjustView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdAdjustView.cpp @@ -248,6 +248,28 @@ namespace OHOS if (TextLabel) { TextLabel->SetText(text); } } } + void ThunderBirdAdjustView::ShowUnbindWarning() + { + if (TextLabel) + { + TextLabel->SetPosition(0, 148, 360, 42); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetText("设备已解绑"); + TextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetPosition(0, 230, 360, 28); + RemindLabel->SetText("等待设备重启"); + RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 25); + RemindLabel->SetVisible(true); + } + if (RemindIcon) { RemindIcon->SetVisible(false);} + if (RemindIcon2) { RemindIcon2->SetVisible(false);} + if (RemindIcon3) { RemindIcon3->SetVisible(false);} + + } } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp index c5c645990..91ab067c1 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp @@ -222,7 +222,7 @@ namespace OHOS ThunderBirdMainView::GetInstance()->OpenBackGround(); if (TextLabel) { - TextLabel->SetPosition(60, 64, 250, 84); + TextLabel->SetPosition(60, 68, 250, 84); TextLabel->SetText("换角色、挑声音、\n哄睡...扫码尽享!"); TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);//自动换行 TextLabel->SetVisible(true); @@ -271,6 +271,14 @@ namespace OHOS qrcode_->Invalidate();//刷新 } } + + void ThunderBirdGuideView::UpdateTextLabel(const char* text) + { + if (TextLabel) + { + TextLabel->SetText(text); + } + } } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp index 9ce3c62f8..868eda3a8 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp @@ -598,15 +598,18 @@ namespace OHOS iconView->SetVisible(false); } backGroundView->SetVisible(false); - if(showView != THUNDERBIRD_DIALOGUEVIEW && showView != THUNDERBIRD_LULLABYVIEW) - { - ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 关闭屏幕常亮 - } - if(currentSubView_ == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING || currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4) - { - //恢复视频帧率 - ThunderBirdModel::GetInstance()->HighFrequence(); - } + // 如果当前界面是需要常亮的界面,则关闭常亮并设置息屏时间 + if((currentView_ == THUNDERBIRD_DIALOGUEVIEW && + (currentSubView_ == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING || + currentSubView_ == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING)) || + (currentView_ == THUNDERBIRD_LULLABYVIEW && currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4)) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::ChangeView: 从常亮界面退出,关闭屏幕常亮,重新设置息屏时间"); + ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 关闭屏幕常亮 + uapi_setScreenDuration(30000); // 重新设置30秒自动息屏 + ThunderBirdModel::GetInstance()->HighFrequence(); + } + // OTA界面已独立为slice,不再需要此检查 // 保存上一级视图信息(如果是GoBackToPreviousView调用,则不更新prevView_和prevSubView_) if (!isGoingBack_) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index 2949e9bd2..9bb5d20bd 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -1210,7 +1210,14 @@ cJSON *hairColor = cJSON_GetObjectItem(characterAvatar, "hairColor"); if (hairColor && cJSON_IsString(hairColor)) { - hairColor_ = std::string(hairColor->valuestring); + if(strcmp(hairColor->valuestring, "warm-orange") == 0)//特殊颜色映射 + { + hairColor_ = "orange"; + } + else//正常颜色映射 + { + hairColor_ = std::string(hairColor->valuestring); + } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::ParseCharacterConfigData: hairColor = %s", hairColor_.c_str()); } @@ -1497,8 +1504,15 @@ // 检查是否是警告界面,需要返回原任务 else if (currentView == THUNDERBIRD_ADJUSTVIEW && currentSubView == ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_WARNING) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "警告界面超时,返回原任务"); - view->GoBackToPreviousView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "警告界面超时,检查是否为解绑警告"); + // 检查是否为解绑警告,如果是则恢复出厂设置 + if (bind_status == true) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "解绑警告界面超时,恢复出厂设置"); + restore_factory_settings(); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "普通警告界面超时,返回原任务"); + view->GoBackToPreviousView(); + } } // 检查是否是任务提醒界面,需要返回原任务 else if (currentView == THUNDERBIRD_REMINDERVIEW && @@ -2137,11 +2151,18 @@ // 检查屏幕状态,如果息屏则自动亮屏 uapi_set_screen_on_api(); // 亮屏 + // 处理特殊颜色映射 + std::string mappedHairColor = hairColor; + if(mappedHairColor == "warm-orange")//特殊颜色映射 + { + mappedHairColor = "orange"; + } + // 构建发型文件路径:/user/res/hair/{hairShape}/{hairColor}.bin std::string hairPath = "/user/res/hair/"; hairPath += hairShape; hairPath += "/"; - hairPath += hairColor; + hairPath += mappedHairColor; hairPath += ".bin"; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SwitchHair: switching to %s", hairPath.c_str()); @@ -2210,8 +2231,15 @@ { if(bind_status == true) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "恢复出厂"); - restore_factory_settings(); + //增加设备解绑提示 + int currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); //获取当前视图 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleBindAndUnbind: 设备已解绑,显示解绑警告"); + ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_ADJUSTVIEW, ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_WARNING); + if(ThunderBirdAdjustView::GetInstance()) + { + ThunderBirdAdjustView::GetInstance()->ShowUnbindWarning(); + } + ThunderBirdModel::GetInstance()->StartCountUpTimer(1); // 2秒后恢复出厂设置 return; } } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp index 4a7d6d1f9..43044cf1d 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -96,7 +96,7 @@ namespace OHOS // uapi_button_register_event_cb(func_button_callback_vendor_down_long_press_5s, BUTTON3_LONGPRESS_5S); // 注册 FUNC 键长按2秒事件 - int32_t ret = uapi_button_register_event_cb(HandleFuncKeyLongPressCallBack, BUTTON1_LONGPRESS_2S); + int32_t ret = uapi_button_register_event_cb(HandleFuncKeyLongPressCallBack, BUTTON1_LONGPRESS_1S); if (ret != ERRCODE_SUCC) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey LongPress Event error, ret = %d", ret); @@ -213,19 +213,38 @@ namespace OHOS */ bool ThunderBirdPresenter::HandlePowerKey(uint16_t keyState, int16_t currentView, int16_t currentSubView, int screenState) { - // 长按关机键 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandlePowerKey: keyState=%d, screenState=%d, isDialogueing=%d, powerKeyPressed=%d", + keyState, screenState, isDialogueing, powerKeyPressed); + + // 长按关机键 - 优先处理 if (keyState == InputDevice::STATE_LONG_PRESS) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandlePowerKey: 长按关机键,进入关机界面"); + powerKeyPressed = false; // 重置标志位 NativeAbility::GetInstance().SwitchSlice(VIEW_REBOOT); return true; } - // 短按POWER键处理 + // 按下电源键 if (keyState == InputDevice::STATE_PRESS) { - if (screenState == 0) { - // 息屏状态下短按:亮屏(由系统自动处理) + powerKeyPressed = true; // 设置按下标志位 + + if (screenState == 1) { + // 息屏状态下按下:亮屏(由系统自动处理) + return true; + } + } + + // 松开电源键 + //判断是否亮屏 + if (keyState == InputDevice::STATE_RELEASE) { + if (!powerKeyPressed) { return true; - } else if (screenState == 1) { - // 亮屏状态下短按:息屏 + } + + powerKeyPressed = false; // 重置标志位 + + if (screenState == 0 && isDialogueing == false) {//对话模式下无效 + // 亮屏状态下松开:息屏 const power_display_svr_api_t *display_api = power_display_svr_get_api(); if (display_api && display_api->get_screen_state() == SCREEN_ON) { display_api->turn_off_screen(); @@ -705,6 +724,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::HandleFuncKeyLongPress"); ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_5); } + else if(currentView == THUNDERBIRD_GUIDEVIEW) + { + ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_3); + ThunderBirdGuideView::GetInstance()->UpdateTextLabel("先小程序扫码绑定\n才能开始对话哦~"); + } } }