• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef OHOS_ABILITY_RUNTIME_RESOURCE_CONFIG_HELPER_H
17 #define OHOS_ABILITY_RUNTIME_RESOURCE_CONFIG_HELPER_H
18 #include "resource_manager.h"
19 #include "configuration.h"
20 #ifdef SUPPORT_GRAPHICS
21 #include "display_manager.h"
22 #endif
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 
27 }
28 namespace AbilityRuntime {
29 class ResourceConfigHelper {
30 public:
31     ResourceConfigHelper() = default;
32     ~ResourceConfigHelper() = default;
33     std::string GetLanguage();
34     void SetLanguage(std::string language);
35     std::string GetLocale();
36     void SetLocale(const std::string& locale);
37     std::string GetColormode();
38     void SetColormode(std::string colormode);
39     std::string GetHasPointerDevice();
40     void SetHasPointerDevice(std::string hasPointerDevice);
41     std::string GetMcc();
42     void SetMcc(std::string mcc);
43     std::string GetMnc();
44     void SetMnc(std::string mnc);
45     void SetThemeId(std::string themeId);
46     void SetThemeIcon(std::string themeIcon);
47     void SetISAbilityColor(bool isSetColorMode);
48     void UpdateResConfig(const AppExecFwk::Configuration &configuration,
49         std::shared_ptr<Global::Resource::ResourceManager> resourceManager);
50 
51     static bool ConvertStringToUint32(std::string source, uint32_t &result);
52 
53 private:
54     std::string language_;
55     std::string locale_;
56     std::string colormode_;
57     std::string hasPointerDevice_;
58     std::string mcc_;
59     std::string mnc_;
60     std::string colorModeIsSetByApp_;
61     std::string themeId_;
62     std::string themeIcon_;
63     bool isSetColorMode_ = false;
64 
65     void UpdateResConfig(std::unique_ptr<Global::Resource::ResConfig> &resConfig);
66 };
67 } // namespace AbilityRuntime
68 } // namespace OHOS
69 #endif  // OHOS_ABILITY_RUNTIME_RESOURCE_CONFIG_HELPER_H
70