1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "form_resource_observer.h" 17 18 #include <thread> 19 20 #include "fms_log_wrapper.h" 21 #include "form_resource_param.h" 22 #include "form_task_mgr.h" 23 #include "configuration.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { FormFwkResourceObserver()27FormFwkResourceObserver::FormFwkResourceObserver() 28 { 29 colorMode_ == FormResourceParam::GetSystemColorMode(); 30 language_ == FormResourceParam::GetSystemLanguage(); 31 } 32 ~FormFwkResourceObserver()33FormFwkResourceObserver::~FormFwkResourceObserver() 34 {} 35 OnConfigurationUpdated(const AppExecFwk::Configuration & configuration)36void FormFwkResourceObserver::OnConfigurationUpdated(const AppExecFwk::Configuration& configuration) 37 { 38 HILOG_INFO("call"); 39 bool needUpdateForms = false; 40 std::string colorMode = configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); 41 if (!colorMode.empty() && colorMode != colorMode_) { 42 HILOG_INFO("colorMode:%{public}s", colorMode.c_str()); 43 needUpdateForms = true; 44 colorMode_ = colorMode; 45 } 46 std::string language = configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE); 47 if (!language.empty() && language != language_) { 48 HILOG_INFO("language:%{public}s", language.c_str()); 49 needUpdateForms = true; 50 language_ = language; 51 } 52 if (needUpdateForms) { 53 FormTaskMgr::GetInstance().PostBatchRefreshForms(Constants::REFRESH_SYSTEMAPP_FORM); 54 } 55 HILOG_INFO("end"); 56 } 57 } // AppExecFwk 58 } // OHOS 59