• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef OHOS_AAFWK_AMS_CONFIGURATION_PARAMETER_H
17 #define OHOS_AAFWK_AMS_CONFIGURATION_PARAMETER_H
18 
19 #include <fstream>
20 #include <nlohmann/json.hpp>
21 
22 namespace OHOS {
23 namespace AAFwk {
24 namespace AmsConfig {
25 const std::string AMS_CONFIG_FILE_PATH {"/system/etc/ams_service_config.json"};
26 const std::string SERVICE_ITEM_AMS {"service_startup_config"};
27 const std::string STARTUP_LAUNCHER {"startup_launcher"};
28 const std::string STARTUP_STATUS_BAR {"startup_system_ui_status_bar"};
29 const std::string STARTUP_NAVIGATION_BAR {"startup_system_ui_navigation_bar"};
30 }  // namespace AmsConfig
31 
32 enum class SatrtUiMode { STATUSBAR = 1, NAVIGATIONBAR = 2, STARTUIBOTH = 3 };
33 
34 class AmsConfigurationParameter final {
35 public:
36     AmsConfigurationParameter() = default;
37     ~AmsConfigurationParameter() = default;
38     /**
39      * return true : ams no config file
40      * return false : ams have config file
41      */
42     bool NonConfigFile() const;
43     /**
44      * return true : ams can start launcher
45      * return false : ams do not start launcher
46      */
47     bool GetStartLauncherState() const;
48     /**
49      * return true : ams can start system ui status bar
50      * return false : ams do not start system ui status bar
51      */
52     bool GetStatusBarState() const;
53     /**
54      * return true : ams can start system ui navigation bar
55      * return false : ams do not start system ui navigation bar
56      */
57     bool GetNavigationBarState() const;
58     /**
59      * Get profile information
60      */
61     void Parse();
62 
63     enum { READ_OK = 0, READ_FAIL = 1, READ_JSON_FAIL = 2 };
64 
65 private:
66     /**
67      * Read the configuration file of ams
68      *
69      */
70     int LoadAmsConfiguration(const std::string &filePath);
71 
72 private:
73     bool nonConfigFile {false};
74     bool canStartLauncher {false};
75     bool canStartUiStatusBar {false};
76     bool canStartUiNavigationBar {false};
77 };
78 }  // namespace AAFwk
79 }  // namespace OHOS
80 #endif  // OHOS_AAFWK_AMS_CONFIGURATION_PARAMETER_H
81