1 /*
2  * Copyright (C) 2021-2022 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_HOTSPOT_SERVICE_H
17 #define OHOS_WIFI_HOTSPOT_SERVICE_H
18 
19 #include <map>
20 #include "iremote_stub.h"
21 #include "message_parcel.h"
22 #include "message_option.h"
23 #include "i_wifi_hotspot.h"
24 
25 namespace OHOS {
26 namespace Wifi {
27 class WifiHotspotStub : public IRemoteStub<IWifiHotspot> {
28 public:
29     using handleFunc = void (WifiHotspotStub::*)(
30         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
31     using HandleFuncMap = std::map<int, handleFunc>;
32 
33     WifiHotspotStub();
34     explicit WifiHotspotStub(int id);
35 
36     virtual ~WifiHotspotStub();
37 
38     virtual int OnRemoteRequest(
39         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
40 
41 private:
42     void InitHandleMap(void);
43     void OnIsHotspotActive(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
44     void OnGetApStateWifi(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
45     void OnGetHotspotConfig(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
46     void OnSetApConfigWifi(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
47     void OnSetApIdleTimeout(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
48     void OnGetStationList(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
49     void OnDisassociateSta(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
50     void OnEnableWifiAp(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
51     void OnDisableWifiAp(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
52     void OnAddBlockList(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
53     void OnDelBlockList(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
54     void OnGetBlockLists(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
55     void OnGetValidBands(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
56     void OnGetValidChannels(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
57     void OnRegisterCallBack(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
58     void OnGetSupportedFeatures(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
59     void OnGetSupportedPowerModel(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
60     void OnGetPowerModel(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
61     void OnSetPowerModel(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
62     void OnIsHotspotDualBandSupported(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
63     void OnGetApIfaceName(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
64     bool CheckHotspot160MParam(BandType band, int bandwidth, int channel);
65     bool CheckHostspot160MCountryCode();
66 
67 private:
68     HandleFuncMap handleFuncMap;
69     std::mutex deathRecipientMutex;
70     sptr<IRemoteObject::DeathRecipient> deathRecipient_;
71     bool mSingleCallback;
72 protected:
73     int m_id;
74 };
75 }  // namespace Wifi
76 }  // namespace OHOS
77 #endif