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_observer/form_resource_observer.h" 17 #include "form_provider/form_provider_task_mgr.h" 18 19 #include <thread> 20 21 #include "fms_log_wrapper.h" 22 #include "form_resource_param.h" 23 #include "form_observer/form_observer_task_mgr.h" 24 #include "configuration.h" 25 26 namespace OHOS { 27 namespace AppExecFwk { FormFwkResourceObserver()28FormFwkResourceObserver::FormFwkResourceObserver() 29 { 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("language: %{public}s colorMode: %{public}s", 39 configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE).c_str(), 40 configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE).c_str()); 41 std::string language = configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE); 42 if (!language.empty() && language != language_) { 43 HILOG_INFO("language changed %{public}s to %{public}s", language_.c_str(), language.c_str()); 44 language_ = language; 45 FormProviderTaskMgr::GetInstance().PostBatchConfigurationUpdateForms(configuration); 46 } 47 HILOG_INFO("end"); 48 } 49 } // AppExecFwk 50 } // OHOS 51