1 /*
2  * Copyright (C) 2023-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_SELF_CURE_SERVICE_H
17 #define OHOS_SELF_CURE_SERVICE_H
18 
19 #include <vector>
20 #include "self_cure_state_machine.h"
21 #include "wifi_errcode.h"
22 #include "define.h"
23 #include "self_cure_common.h"
24 #include "wifi_service_manager.h"
25 #include "ienhance_service.h"
26 #include "ip2p_service_callbacks.h"
27 
28 namespace OHOS {
29 namespace Wifi {
30 class SelfCureService {
31     FRIEND_GTEST(SelfCureService);
32 public:
33     explicit SelfCureService(int instId = 0);
34     virtual ~SelfCureService();
35     virtual ErrCode InitSelfCureService();
36     virtual void RegisterSelfCureServiceCallback(const std::vector<SelfCureServiceCallback> &callbacks) const;
37     void HandleRssiLevelChanged(int rssi);
38     void HandleStaConnChanged(OperateResState state, const WifiLinkedInfo &info);
39     void HandleStaOpened();
40     void HandleP2pConnChanged(const WifiP2pLinkedInfo &info);
41     void HandleDhcpOfferReport(const IpInfo &ipInfo);
42     void NotifyInternetFailureDetected(int forceNoHttpCheck);
43     bool IsSelfCureOnGoing();
44 private:
45     void RegisterP2pEnhanceCallback();
46     void UnRegisterP2pEnhanceCallback();
47     void P2pEnhanceStateChange(const std::string &ifName, int32_t state);
48 private:
49     SelfCureStateMachine *pSelfCureStateMachine;
50     int m_instId;
51     P2pEnhanceCallback p2pEnhanceStateChange_;
52     int32_t lastP2pEnhanceState_ = -1;
53     OperateResState lastState = OperateResState::DISCONNECT_DISCONNECTED;
54     WifiLinkedInfo lastWifiLinkedInfo;
55 };
56 } //namespace Wifi
57 } //namespace OHOS
58 #endif