• 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 IMF_SYSTEM_PARAM_ADAPTER_H
17 #define IMF_SYSTEM_PARAM_ADAPTER_H
18 
19 #include <string>
20 namespace OHOS {
21 namespace MiscServices {
22 class SystemParamAdapter {
23 public:
24     static constexpr const char *SYSTEM_LANGUAGE_KEY = "persist.global.language";
25     static constexpr const char *MEMORY_WATERMARK_KEY = "resourceschedule.memmgr.min.memmory.watermark";
26     static SystemParamAdapter &GetInstance();
27     int32_t WatchParam(const std::string &key);
28     bool GetBoolParam(const std::string &key);
29 
30 private:
31     SystemParamAdapter() = default;
32     using CbHandler = void (*)(const char *key, const char *value, void *context);
33     static const std::unordered_map<std::string, CbHandler> PARAM_CB_HANDLERS;
34     static void OnLanguageChange(const char *key, const char *value, void *context);
35     static void OnMemoryChange(const char *key, const char *value, void *context);
36     static void HandleSysParamChanged(const char *key, const char *value, const char *expectedKey, int32_t messageId);
37 };
38 } // namespace MiscServices
39 } // namespace OHOS
40 
41 #endif // IMF_SYSTEM_PARAM_ADAPTER_H
42