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 
16 #ifndef OHOS_WIFI_SCAN_STUB_H
17 #define OHOS_WIFI_SCAN_STUB_H
18 
19 #include <map>
20 #include "iremote_stub.h"
21 #include "i_wifi_scan.h"
22 
23 namespace OHOS {
24 namespace Wifi {
25 class WifiScanStub : public IRemoteStub<IWifiScan> {
26 public:
27     using handleFunc = int (WifiScanStub::*)(
28     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
29     using HandleFuncMap = std::map<int, handleFunc>;
30     WifiScanStub();
31     explicit WifiScanStub(int instId);
32     virtual ~WifiScanStub() override;
33 
34     virtual int OnRemoteRequest(
35         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
36 
37     bool IsSingleCallback() const;
38     void SetSingleCallback(const bool isSingleCallback);
39 
40 private:
41     void InitHandleMap();
42     int OnSetScanControlInfo(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
43     int OnScan(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
44     int OnScanByParams(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
45     int OnIsWifiClosedScan(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
46     int OnGetScanInfoList(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
47     int OnRegisterCallBack(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
48     int OnGetSupportedFeatures(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
49     int OnSetScanOnlyAvailable(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
50     int OnGetScanOnlyAvailable(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
51     int OnStartWifiPnoScan(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
52     void SendScanInfo(int32_t contentSize, std::vector<WifiScanInfo> &result, MessageParcel &reply);
53     void SendScanInfoSmall(int32_t contentSize, std::vector<WifiScanInfo> &result, MessageParcel &reply);
54     std::mutex deathRecipientMutex;
55     sptr<IRemoteObject::DeathRecipient> deathRecipient_;
56     HandleFuncMap handleFuncMap;
57     bool mSingleCallback;
58 
59 protected:
60     int m_instId{0};
61 };
62 }  // namespace Wifi
63 }  // namespace OHOS
64 #endif
65