1 /* 2 * Copyright (c) 2021 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 #ifndef OHOS_AAFWK_CONFIGURATION_HOLDER_H 16 #define OHOS_AAFWK_CONFIGURATION_HOLDER_H 17 18 #include "aafwk_dummy_configuration.h" 19 20 #include <memory> 21 22 namespace OHOS { 23 namespace AAFwk { 24 /** 25 * @class AbilityRecord 26 * AbilityRecord records ability info and states and used to schedule ability life. 27 */ 28 class ConfigurationHolder { 29 public: 30 ConfigurationHolder() = default; 31 virtual ~ConfigurationHolder() = default; 32 33 void Init(const std::shared_ptr<DummyConfiguration> &config); 34 void UpdateConfiguration(const std::shared_ptr<DummyConfiguration> config); 35 std::shared_ptr<DummyConfiguration> GetConfiguration() const; 36 bool ProcessConfigurationChange(); 37 bool ForceProcessConfigurationChange(const std::shared_ptr<DummyConfiguration> &config); 38 39 protected: 40 virtual bool OnConfigurationChanged(const DummyConfiguration &config, unsigned int configChanges); 41 virtual std::shared_ptr<ConfigurationHolder> GetParent() = 0; 42 virtual unsigned int GetChildSize() = 0; 43 virtual std::shared_ptr<ConfigurationHolder> FindChild(unsigned int index) = 0; 44 45 static constexpr unsigned int CHANGE_CONFIG_ALL_CHANGED = 0xFFFFFFFF; 46 static constexpr unsigned int CHANGE_CONFIG_NONE = 0x00000000; 47 static constexpr unsigned int CHANGE_CONFIG_LOCALE = 0x00000001; 48 static constexpr unsigned int CHANGE_CONFIG_LAYOUT = 0x00000002; 49 static constexpr unsigned int CHANGE_CONFIG_FONTSIZE = 0x00000004; 50 static constexpr unsigned int CHANGE_CONFIG_ORIENTATION = 0x00000008; 51 static constexpr unsigned int CHANGE_CONFIG_DENSITY = 0x00000010; 52 53 private: 54 void DealUpdateConfiguration(); 55 bool ProcessConfigurationChangeInner(const std::shared_ptr<DummyConfiguration> &config); 56 57 private: 58 std::shared_ptr<DummyConfiguration> baseConfiguration_ = nullptr; 59 }; 60 } // namespace AAFwk 61 } // namespace OHOS 62 #endif // OHOS_AAFWK_CONFIGURATION_HOLDER_H