• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #ifndef OHOS_ABILITY_RUNTIME_CONFIGURATION_UTILS_H
17 #define OHOS_ABILITY_RUNTIME_CONFIGURATION_UTILS_H
18 
19 #include "configuration.h"
20 #ifdef SUPPORT_GRAPHICS
21 #include "display_manager.h"
22 #endif
23 #include "resource_manager.h"
24 
25 namespace OHOS {
26 namespace AbilityRuntime {
27 class ConfigurationUtils {
28 public:
29     ConfigurationUtils() = default;
30     ~ConfigurationUtils() = default;
31     using Configuration = AppExecFwk::Configuration;
32     using ResourceManager = Global::Resource::ResourceManager;
33 
34     /**
35      * @brief Update global configuration to resource manager.
36      *
37      * @param configuration configuration
38      * @param resourceManager resource manager
39      */
40     void UpdateGlobalConfig(const Configuration &configuration, std::shared_ptr<ResourceManager> resourceManager);
41 
42 private:
43     void GetGlobalConfig(const Configuration &configuration, std::string &language, std::string &colormode,
44         std::string &hasPointerDevice);
45 
46 #ifdef SUPPORT_GRAPHICS
47 public:
48     /**
49      * @brief Init display configuration to context configuration and resource manager.
50      *
51      * @param displayId Display ID
52      * @param configuration Context configuration need to add display config
53      * @param resourceManager Resource manager instance need to add display config
54      */
55     void InitDisplayConfig(Rosen::DisplayId displayId, std::shared_ptr<Configuration> configuration,
56         std::shared_ptr<ResourceManager> resourceManager);
57 
58     /**
59      * @brief Update display configuration to context configuration and resource manager.
60      *
61      * @param displayId Display ID
62      * @param configuration Context configuration need to add display config
63      * @param resourceManager Resource manager instance need to add display config
64      * @param configChanged If configuration has changed, set to true
65      */
66     void UpdateDisplayConfig(Rosen::DisplayId displayId, std::shared_ptr<Configuration> configuration,
67         std::shared_ptr<ResourceManager> resourceManager, bool &configChanged);
68 
69 private:
70     bool GetDisplayConfig(Rosen::DisplayId displayId, float &density, std::string &directionStr);
71     void UpdateDisplayResConfig(std::shared_ptr<ResourceManager> resourceManager, float &density,
72         std::string &direction);
73 #endif
74 };
75 } // namespace AbilityRuntime
76 } // namespace OHOS
77 #endif  // OHOS_ABILITY_RUNTIME_CONFIGURATION_UTILS_H
78