get config

Signed-off-by: zhuhan <2281542033@qq.com>
Change-Id: I8a0e547a5812cedce1c872f168ddd02830b2346d
This commit is contained in:
zhuhan 2024-07-26 22:00:13 +08:00
parent 8a3894b95e
commit bf29297393
5 changed files with 37 additions and 0 deletions

View File

@ -676,6 +676,24 @@ void ApplicationContext::SwitchArea(int mode)
}
}
void ApplicationContext::SetConfiguration(const std::shared_ptr<AppExecFwk::Configuration> &config)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "context is null");
return;
}
contextImpl_->SetConfiguration(config);
}
void ApplicationContext::AppHasDarkRes(bool &darkRes)
{
if (contextImpl_ == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "context is null");
return;
}
contextImpl_->AppHasDarkRes(darkRes);
}
void ApplicationContext::SetColorMode(int32_t colorMode)
{
TAG_LOGD(AAFwkTag::APPKIT, "colorMode:%{public}d.", colorMode);

View File

@ -1084,6 +1084,19 @@ void ContextImpl::SetConfiguration(const std::shared_ptr<AppExecFwk::Configurati
config_ = config;
}
void ContextImpl::AppHasDarkRes(bool &darkRes)
{
std::shared_ptr<Global::Resource::ResourceManager> currentResMgr = GetResourceManager();
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
if (currentResMgr == nullptr || resConfig == nullptr) {
TAG_LOGE(AAFwkTag::APPKIT, "resMgr or resConfig is null");
return;
}
currentResMgr->GetResConfig(*resConfig);
darkRes = resConfig->GetAppDarkRes();
TAG_LOGD(AAFwkTag::APPKIT, "darkRes %{public}d", darkRes);
}
void ContextImpl::KillProcessBySelf(const bool clearPageStack)
{
TAG_LOGD(AAFwkTag::APPKIT, "killProcessBySelf called clearPageStack is %{public}d.", clearPageStack);

View File

@ -558,6 +558,8 @@ void OHOSApplication::OnConfigurationUpdated(Configuration config)
configuration_->RemoveItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_SA);
configuration_->RemoveItem(AAFwk::GlobalConfigurationKey::COLORMODE_NEED_REMOVE_SET_BY_SA);
}
abilityRuntimeContext_->SetConfiguration(configuration_);
}
/**

View File

@ -114,6 +114,8 @@ public:
void ClearUpApplicationData();
int GetArea() override;
std::shared_ptr<AppExecFwk::Configuration> GetConfiguration() const override;
void SetConfiguration(const std::shared_ptr<AppExecFwk::Configuration> &config);
void AppHasDarkRes(bool &darkRes);
std::string GetBaseDir() const override;
Global::Resource::DeviceType GetDeviceType() const override;
void KillProcessBySelf(const bool clearPageStack = true);

View File

@ -370,6 +370,8 @@ public:
void PrintTokenInfo() const;
void AppHasDarkRes(bool &darkRes);
static const int EL_DEFAULT = 1;
protected: