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_WIFICOMMONSERVICEMANAGER_H
16 #define OHOS_WIFICOMMONSERVICEMANAGER_H
17 
18 #include <string>
19 #include <sys/stat.h>
20 #include <fcntl.h>
21 #include "define.h"
22 #include "wifi_internal_msg.h"
23 #include "wifi_errcode.h"
24 #include "wifi_manager.h"
25 #ifndef OHOS_ARCH_LITE
26 #include "wifi_app_state_aware.h"
27 #include "wifi_net_agent.h"
28 #include "wifi_event_subscriber_manager.h"
29 #endif
30 #include "wifi_netlink.h"
31 #ifdef FEATURE_SELF_CURE_SUPPORT
32 #include "ip_qos_monitor.h"
33 #endif
34 
35 namespace OHOS {
36 namespace Wifi {
37 class WifiCommonServiceManager {
38 public:
39     static WifiCommonServiceManager &GetInstance();
40     ~WifiCommonServiceManager();
41     /**
42      * @Description Initialize submodules and message processing threads.
43      *              1. Initializing the Configuration Center
44      *              2. Initialization permission management
45      *              3. Initializing Service Management
46      *              4. Initialization event broadcast
47      *              5. Initializing a Message Queue
48      *              6. Initialize the message processing thread
49      *
50      * @return int - Init result, when 0 means success, other means some fails happened.
51      */
52     InitStatus Init();
53 
54     /**
55      * @Description When exiting, the system exits each submodule and then exits the message processing thread.
56      *              1. Uninstall each feature service
57      *              2. Exit the event broadcast module
58      *              3. Wait for the message processing thread to exit
59      *
60      */
61     void Exit();
62 
63 #ifndef OHOS_ARCH_LITE
64     void OnForegroundAppChanged(const AppExecFwk::AppStateData &appStateData, const int mInstId = 0);
65 #endif
66     bool OnRequestNetwork(const int uid, const int networkId);
67 #ifdef FEATURE_SELF_CURE_SUPPORT
68     void OnTcpReportMsgComplete(const std::vector<int64_t> &elems, const int32_t cmd, const int32_t mInstId = 0);
69 #endif
70 
71 private:
72     WifiCommonServiceManager();
73 private:
74 #ifndef OHOS_ARCH_LITE
75     WifiAppStateAwareCallbacks mWifiAppStateAwareCallbacks;
76     WifiNetAgentCallbacks wifiNetAgentCallbacks_;
77 #endif
78 #ifdef FEATURE_SELF_CURE_SUPPORT
79     WifiNetLinkCallbacks mWifiNetLinkCallbacks;
80 #endif
81 };
82 } // namespace Wifi
83 } // namespace OHOS
84 #endif