From: xue <2144439972@qq.com> Date: Fri, 26 Sep 2025 07:20:35 +0000 (+0800) Subject: 修复息屏切换表情bug X-Git-Tag: V1.0.9_20251128_194606_LN~250^2~45^2~3 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=d2c5066d6720623c32fafcfc95d834b5681d78a4;p=mirrors%2FFD230.git 修复息屏切换表情bug --- diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h index cad401fc6..235b07faa 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h @@ -166,9 +166,24 @@ namespace OHOS // 任务提醒处理函数 void HandleTaskReminder(const char* scheduleName); + // 角色配置更改处理函数 + void HandleCharacterConfigChange(const char* characterId, const char* characterName, + const char* eyesShape, const char* hairColor, + const char* eyesColor, const char* hairStyle, + int screenImageAsEmoji); + // 表情切换函数 bool SwitchExpression(const char* eyeShape, const char* eyeColor); - + + // 发型切换函数 + bool SwitchHair(const char* hairShape, const char* hairColor); + + // 表情视频切换函数 + bool SwitchExpressionVideo(const char* videoPath); + + // 哄睡模式处理函数 + void HandleSleepModeStart(const char* theme); + void HandleSleepModeEnd(); // 减低视频帧率 void LowFrequence(); // 恢复视频帧率 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp index a607394b1..bd6177e8b 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp @@ -349,11 +349,13 @@ namespace OHOS RemindIcon2->SetSrc("/user/res/volume_up.bin"); RemindIcon2->SetVisible(true); } + break; } case THUNDERBIRD_LULLABYVIEW_4: { - ThunderBirdModel::GetInstance()->StartCountUpTimer(15 * 60); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::Show: THUNDERBIRD_LULLABYVIEW_4"); + //ThunderBirdModel::GetInstance()->StartCountUpTimer(15 * 60); if (TextLabel) { TextLabel->SetPosition(0, 64, 360, 42); @@ -373,7 +375,6 @@ namespace OHOS ThunderBirdLullabyView::UpdateLullabyText(ThunderBirdModel::GetInstance()->GetTextStr().c_str()); if(RemindLabel) { - RemindLabel->SetPosition(115, 114, 131, 28); RemindLabel->SetText("04:00/15:00"); RemindLabel->SetVisible(true); 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 975227305..9d16d3c02 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 @@ -337,6 +337,7 @@ namespace OHOS Surface *surface = surfaceView_->GetSurface(); if (surface == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::SwitchVideo: Failed to get surface from surfaceView_"); return false; } @@ -344,11 +345,19 @@ namespace OHOS videoPlay_ = new MediaVideoPlay(surface, nullptr, std::string(uri), true); if (videoPlay_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::SwitchVideo: Failed to create MediaVideoPlay"); return false; } g_videoPlay = videoPlay_; int32_t ret = videoPlay_->StartVideoPlay(); - return (ret == 0); + if (ret != 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::SwitchVideo: Failed to start video play, ret=%d", ret); + return false; + } + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::SwitchVideo: Successfully switched to video: %s", uri); + return true; } void ThunderBirdMainView::CloseVideo() // 关闭表情接口 @@ -383,6 +392,7 @@ namespace OHOS curFace = nullptr; } } + // OTA界面已独立为slice,不再需要此函数 @@ -628,7 +638,7 @@ namespace OHOS curFace->SetResizeMode(UIImageView::COVER); curFace->SetStyle(STYLE_BACKGROUND_OPA, 0x00); //curFace->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe0c7c1); - curFace->SetSrc("/user/res/hair/curly/orange.bin"); + curFace->SetSrc("/user/res/hair/curly-hair/orange.bin"); surfaceView_ = new UILiteSurfaceView(); if (surfaceView_ == nullptr) @@ -656,7 +666,7 @@ namespace OHOS surface->SetSize(bufferSize); if (videoPlay_ == nullptr) { - std::string uri("/user/res/video/CloseEyes/RoundEyes/amber.mp4"); + std::string uri("/user/res/video/CloseEyes/round-eyes/amber.mp4"); videoPlay_ = new MediaVideoPlay(surface, nullptr, uri, true); if (videoPlay_ == nullptr) { 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 9870c7e2f..4067bc014 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 @@ -29,10 +29,9 @@ #include "custom_runtime.h" #include "ln_api.h" #include "kv_store.h" - #include "AppViewIDs.h" - #include "NativeRegisterManager.h" - #include "graphic_service_wrapper.h" - + #include "power_display_service.h" +#include "AppViewIDs.h" +#include "NativeRegisterManager.h" #define JUHEPINGTAI 1 #if JUHEPINGTAI #include "websocket_server_manager.h" @@ -1479,33 +1478,140 @@ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Processing task reminder: %s", scheduleName); } } + + void ThunderBirdModel::HandleCharacterConfigChange(const char* characterId, const char* characterName, + const char* eyesShape, const char* hairColor, + const char* eyesColor, const char* hairStyle, + int screenImageAsEmoji) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleCharacterConfigChange"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " characterId: %s", characterId ? characterId : "null"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " characterName: %s", characterName ? characterName : "null"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " eyesShape: %s", eyesShape ? eyesShape : "null"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " hairColor: %s", hairColor ? hairColor : "null"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " eyesColor: %s", eyesColor ? eyesColor : "null"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " hairStyle: %s", hairStyle ? hairStyle : "null"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " screenImageAsEmoji: %d", screenImageAsEmoji); + + // 这里可以添加角色配置更改的具体处理逻辑 + // 例如: + // 1. 更新角色外观显示 + // 2. 保存角色配置到本地存储 + // 3. 通知UI更新角色显示 + // 4. 如果screenImageAsEmoji为true,可能需要更新表情显示 + + // 示例:调用表情切换功能 + if (eyesShape && eyesColor) { + SwitchExpression(eyesShape, eyesColor); + } + + // 切换发型功能 + if (hairStyle && hairColor) { + SwitchHair(hairStyle, hairColor); + } + + // SaveCharacterConfig(characterId, characterName, eyesShape, hairColor, eyesColor, hairStyle, screenImageAsEmoji); + } + bool ThunderBirdModel::SwitchExpression(const char* eyeShape, const char* eyeColor) { // 参数验证 if (eyeShape == nullptr || eyeColor == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SwitchExpression: invalid parameters"); return false; } + // 检查屏幕状态,如果息屏则自动亮屏 + uapi_set_screen_on_api(); // 亮屏 + // 构建表情文件路径:/user/res/video/CloseEyes/{eyeShape}/{eyeColor}.mp4 std::string expressionPath = "/user/res/video/CloseEyes/"; expressionPath += eyeShape; expressionPath += "/"; expressionPath += eyeColor; expressionPath += ".mp4"; - + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SwitchExpression: switching to %s", expressionPath.c_str()); // 通过图形服务调用 ThunderBirdMainView 的 SwitchVideo 函数 - bool result = false; + // 注意:PostGraphicEvent 是异步的,这里直接返回 true 表示调用已提交 GraphicService::GetInstance()->PostGraphicEvent( - [expressionPath, &result]() { + [expressionPath]() { if (ThunderBirdMainView::GetInstance()) { - result = ThunderBirdMainView::GetInstance()->SwitchVideo(expressionPath.c_str()); + ThunderBirdMainView::GetInstance()->SwitchVideo(expressionPath.c_str()); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SwitchExpression: ThunderBirdMainView instance is null"); } }); - return result; + return true; // 异步调用,返回 true 表示调用已提交 } - //减低视频帧率 开启对话调用开启 + bool ThunderBirdModel::SwitchExpressionVideo(const char* videoPath) + { + // 参数验证 + if (videoPath == nullptr) { + return false; + } + + // 通过图形服务调用 ThunderBirdMainView 的 SwitchVideo 函数 + // 注意:PostGraphicEvent 是异步的,这里直接返回 true 表示调用已提交 + GraphicService::GetInstance()->PostGraphicEvent( + [videoPath]() { + if (ThunderBirdMainView::GetInstance()) { + ThunderBirdMainView::GetInstance()->SwitchVideo(videoPath); + } + }); + + return true; // 异步调用,返回 true 表示调用已提交 + } + //切换发型 + bool ThunderBirdModel::SwitchHair(const char* hairShape, const char* hairColor) + { + // 参数验证 + if (hairShape == nullptr || hairColor == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SwitchHair: invalid parameters"); + return false; + } + + // 检查屏幕状态,如果息屏则自动亮屏 + uapi_set_screen_on_api(); // 亮屏 + + // 构建发型文件路径:/user/res/hair/{hairShape}/{hairColor}.bin + std::string hairPath = "/user/res/hair/"; + hairPath += hairShape; + hairPath += "/"; + hairPath += hairColor; + hairPath += ".bin"; + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SwitchHair: switching to %s", hairPath.c_str()); + + // 通过图形服务调用 ThunderBirdMainView 的 SwitchHair 函数 + // 注意:PostGraphicEvent 是异步的,这里直接返回 true 表示调用已提交 + GraphicService::GetInstance()->PostGraphicEvent( + [hairPath]() { + if (ThunderBirdMainView::GetInstance()) { + ThunderBirdMainView::GetInstance()->SwitchHair(hairPath.c_str()); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SwitchHair: ThunderBirdMainView instance is null"); + } + }); + return true; // 异步调用,返回 true 表示调用已提交 + } + + void ThunderBirdModel::HandleSleepModeStart(const char* theme) + { + int currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); //获取当前视图 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleSleepModeStart"); + ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_2); + } + + void ThunderBirdModel::HandleSleepModeEnd() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleSleepModeEnd"); + int currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); //获取当前视图 + ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_5); + } + //减低视频帧率 开启对话调用开启 void ThunderBirdModel::LowFrequence() { SetFrequence(LOW_FREQUENCE); @@ -1527,5 +1633,7 @@ { return m_currentFps; } - } + + +} \ No newline at end of file