1 /* 2 * Copyright (C) 2021-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_WIFI_SERVICE_SCHEDULER_H 17 #define OHOS_WIFI_SERVICE_SCHEDULER_H 18 19 #include <string> 20 #include "wifi_logger.h" 21 #include "wifi_errcode.h" 22 #include "sta_service_callback.h" 23 #include "iscan_service_callbacks.h" 24 #ifdef FEATURE_AP_SUPPORT 25 #include "i_ap_service_callbacks.h" 26 #endif 27 #ifdef FEATURE_P2P_SUPPORT 28 #include "ip2p_service_callbacks.h" 29 #endif 30 #include "wifi_internal_msg.h" 31 #include "wifi_controller_define.h" 32 #include "wifi_service_manager.h" 33 #include "state.h" 34 35 namespace OHOS { 36 namespace Wifi { 37 class WifiServiceScheduler { 38 public: 39 static WifiServiceScheduler &GetInstance(); 40 explicit WifiServiceScheduler(); 41 ~WifiServiceScheduler(); 42 ErrCode AutoStartStaService(int instId, std::string &staIfName); 43 ErrCode AutoStartWifi2Service(int instId, std::string &staIfName); 44 ErrCode AutoStopStaService(int instId); 45 ErrCode AutoStopWifi2Service(int instId); 46 ErrCode AutoStartScanOnly(int instId, std::string &staIfName); 47 ErrCode AutoStopScanOnly(int instId, bool setIfaceDown); 48 ErrCode AutoStartSemiStaService(int instId, std::string &staIfName); 49 ErrCode AutoStartApService(int instId, std::string &softApIfName); 50 ErrCode AutoStopApService(int instId); 51 void DispatchWifiOpenRes(OperateResState state, int instId); 52 void DispatchWifi2OpenRes(OperateResState state, int instId); 53 void DispatchWifiSemiActiveRes(OperateResState state, int instId); 54 void DispatchWifiCloseRes(OperateResState state, int instId); 55 void DispatchWifi2CloseRes(OperateResState state, int instId); 56 void ClearStaIfaceNameMap(int instId); 57 void ClearP2pIfaceNameMap(int instId); 58 void ClearSoftApIfaceNameMap(int instId); 59 private: 60 ErrCode PreStartWifi(int instId, std::string &staIfName); 61 ErrCode PostStartWifi(int instId); 62 ErrCode PostStartWifi2(int instId); 63 ErrCode InitStaService(IStaService *pService, int instId); 64 ErrCode StartWifiStaService(int instId); 65 ErrCode StartDependentService(int instId); 66 void HandleGetStaFailed(int instId); 67 #ifdef FEATURE_WIFI_PRO_SUPPORT 68 ErrCode StartWifiProService(int instId); 69 #endif 70 #ifdef FEATURE_SELF_CURE_SUPPORT 71 ErrCode StartSelfCureService(int instId); 72 #endif 73 ErrCode TryToStartApService(int instId); 74 #ifdef HDI_CHIP_INTERFACE_SUPPORT 75 void StaIfaceDestoryCallback(std::string &destoryIfaceName, int createIfaceType); 76 void P2pIfaceDestoryCallback(std::string &destoryIfaceName, int createIfaceType); 77 void SoftApIfaceDestoryCallback(std::string &destoryIfaceName, int createIfaceType); 78 void OnRssiReportCallback(int index, int antRssi); 79 #endif 80 std::map<int, std::string> staIfaceNameMap; 81 std::map<int, std::string> softApIfaceNameMap; 82 std::mutex mutex; 83 }; 84 } 85 } 86 #endif