!10436 窗口新增重启后通知rs深色模式逻辑

Merge pull request !10436 from kk/master
This commit is contained in:
openharmony_ci 2024-11-05 01:43:18 +00:00 committed by Gitee
commit 712410261a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 46 additions and 0 deletions

View File

@ -108,6 +108,7 @@ ohos_shared_library("scene_session_manager") {
"ability_runtime:ability_deps_wrapper",
"ability_runtime:ability_manager",
"ability_runtime:ability_start_setting",
"ability_runtime:app_context",
"ability_runtime:app_manager",
"ability_runtime:mission_info",
"ability_runtime:session_handler",

View File

@ -631,6 +631,7 @@ private:
void UpdateNormalSessionAvoidArea(const int32_t& persistentId, sptr<SceneSession>& sceneSession, bool& needUpdate);
void UpdateAvoidArea(int32_t persistentId);
void UpdateAvoidAreaByType(int32_t persistentId, AvoidAreaType type);
void UpdateDarkColorModeToRS();
WSError IsLastFrameLayoutFinished(bool& isLayoutFinished);
void HandleSpecificSystemBarProperty(WindowType type, const sptr<WindowSessionProperty>& property,
const sptr<SceneSession>& sceneSession);

View File

@ -19,6 +19,7 @@
#include <ability_context.h>
#include <ability_manager_client.h>
#include <application_context.h>
#include <bundlemgr/launcher_service.h>
#include <hisysevent.h>
#include <parameters.h>
@ -308,6 +309,7 @@ void SceneSessionManager::Init()
MultiInstanceManager::GetInstance().SetCurrentUserId(currentUserId_);
}
InitVsyncStation();
UpdateDarkColorModeToRS();
}
void SceneSessionManager::InitVsyncStation()
@ -8430,6 +8432,25 @@ WSError SceneSessionManager::UpdateSessionWindowVisibilityListener(int32_t persi
return taskScheduler_->PostSyncTask(task, "UpdateSessionWindowVisibilityListener");
}
void SceneSessionManager::UpdateDarkColorModeToRS()
{
std::shared_ptr<AbilityRuntime::ApplicationContext> appContext = AbilityRuntime::Context::GetApplicationContext();
if (appContext == nullptr) {
TLOGE(WmsLogTag::DEFAULT, "app context is nullptr");
return;
}
std::shared_ptr<AppExecFwk::Configuration> config = appContext->GetConfiguration();
if (config == nullptr) {
TLOGE(WmsLogTag::DEFAULT, "app configuration is nullptr");
return;
}
std::string colorMode = config->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE);
bool isDark = (colorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK);
bool ret = RSInterfaces::GetInstance().SetGlobalDarkColorMode(isDark);
TLOGI(WmsLogTag::DEFAULT, "SetGlobalDarkColorMode with colorMode: %{public}s, ret: %{public}d",
colorMode.c_str(), ret);
}
void SceneSessionManager::SetVirtualPixelRatioChangeListener(const ProcessVirtualPixelRatioChangeFunc& func)
{
processVirtualPixelRatioChangeFunc_ = func;

View File

@ -616,6 +616,7 @@ ohos_unittest("ws_scene_session_manager_test4") {
"ability_base:configuration",
"ability_base:session_info",
"ability_runtime:ability_context_native",
"ability_runtime:app_context",
"ability_runtime:mission_info",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",

View File

@ -15,6 +15,7 @@
#include <gtest/gtest.h>
#include <regex>
#include <application_context.h>
#include <bundle_mgr_interface.h>
#include <bundlemgr/launcher_service.h>
@ -630,6 +631,27 @@ HWTEST_F(SceneSessionManagerTest4, UpdateSessionWindowVisibilityListener02, Func
EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
}
/**
* @tc.name: UpdateDarkColorModeToRS
* @tc.desc: UpdateDarkColorModeToRS
* @tc.type: FUNC
* @tc.require: issueIB1N43
*/
HWTEST_F(SceneSessionManagerTest4, UpdateDarkColorModeToRS, Function | SmallTest | Level3)
{
ASSERT_NE(nullptr, ssm_);
AbilityRuntime::ApplicationContext::applicationContext_ =
std::make_shared<AbilityRuntime::ApplicationContext>();
ASSERT_NE(nullptr, AbilityRuntime::ApplicationContext::applicationContext_);
AbilityRuntime::ApplicationContext::applicationContext_->contextImpl_ =
std::make_shared<AbilityRuntime::ContextImpl>();
ASSERT_NE(nullptr, AbilityRuntime::ApplicationContext::applicationContext_->contextImpl_);
AbilityRuntime::ApplicationContext::applicationContext_->contextImpl_->config_ =
std::make_shared<AppExecFwk::Configuration>();
ASSERT_NE(nullptr, AbilityRuntime::ApplicationContext::applicationContext_->GetConfiguration());
ssm_->UpdateDarkColorModeToRS();
}
/**
* @tc.name: NotifySessionAINavigationBarChange
* @tc.desc: NotifySessionAINavigationBarChange