• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     void HandleRssiLevelChanged(int rssi);
37     void HandleStaConnChanged(OperateResState state, const WifiLinkedInfo &info);
38     void HandleDhcpOfferReport(const IpInfo &ipInfo);
39     void NotifyInternetFailureDetected(int forceNoHttpCheck);
40     void NotifyP2pConnectStateChanged(const WifiP2pLinkedInfo &info);
41     bool IsSelfCureOnGoing();
42     bool IsSelfCureL2Connecting();
43     void StopSelfCureWifi(int32_t status);
44     bool CheckSelfCureWifiResult(int event);
45     bool IsWifiSelfcureDone();
46 private:
47     void RegisterP2pEnhanceCallback();
48     void P2pEnhanceStateChange(const std::string &ifName, int32_t state, int32_t frequency);
49 private:
50     SelfCureStateMachine *pSelfCureStateMachine;
51     int m_instId;
52     int32_t lastP2pEnhanceState_ = -1;
53     OperateResState lastState = OperateResState::DISCONNECT_DISCONNECTED;
54     OperateResState lastNetworkState_ = OperateResState::DISCONNECT_DISCONNECTED;
55     WifiLinkedInfo lastWifiLinkedInfo;
56 };
57 } //namespace Wifi
58 } //namespace OHOS
59 #endif