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 #ifndef OHOS_WIFI_P2P_STUB_H 16 #define OHOS_WIFI_P2P_STUB_H 17 18 #include <map> 19 #include "iremote_stub.h" 20 #include "message_parcel.h" 21 #include "message_option.h" 22 #include "i_wifi_p2p.h" 23 24 namespace OHOS { 25 namespace Wifi { 26 class WifiP2pStub : public IRemoteStub<IWifiP2p> { 27 public: 28 using handleFunc = void (WifiP2pStub::*)( 29 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 30 using HandleFuncMap = std::map<int, handleFunc>; 31 32 WifiP2pStub(); 33 34 virtual ~WifiP2pStub(); 35 36 virtual int OnRemoteRequest( 37 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 38 39 bool IsSingleCallback() const; 40 void SetSingleCallback(const bool isSingleCallback); 41 42 virtual ErrCode MonitorCfgChange(void) = 0; 43 44 private: 45 void InitHandleMap(void); 46 void InitHandleMapEx(void); 47 void OnEnableP2p(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 48 void OnDisableP2p(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 49 void OnDiscoverDevices(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 50 void OnStopDiscoverDevices(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 51 void OnDiscoverServices(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 52 void OnStopDiscoverServices(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 53 void OnRequestService(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 54 void OnPutLocalP2pService(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 55 void OnDeleteLocalP2pService(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 56 void OnStartP2pListen(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 57 void OnStopP2pListen(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 58 void OnCreateGroup(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 59 void OnRemoveGroup(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 60 void OnRemoveGroupClient(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 61 void OnDeleteGroup(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 62 void OnP2pConnect(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 63 void OnP2pCancelConnect(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 64 void OnQueryP2pLinkedInfo(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 65 void OnGetCurrentGroup(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 66 void OnGetP2pEnableStatus(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 67 void OnGetP2pDiscoverStatus(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 68 void OnGetP2pConnectedStatus(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 69 void OnQueryP2pDevices(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 70 void OnQueryP2pGroups(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 71 void OnQueryP2pServices(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 72 void OnRegisterCallBack(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 73 void OnGetSupportedFeatures(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 74 void OnSetP2pDeviceName(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 75 void OnSetP2pWfdInfo(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 76 void OnHid2dRequestGcIp(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 77 void OnHid2dSharedlinkIncrease(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 78 void OnHid2dSharedlinkDecrease(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 79 void OnHid2dCreateGroup(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 80 void OnHid2dRemoveGcGroup(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 81 void OnHid2dConnect(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 82 void OnHid2dConfigIPAddr(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 83 void OnHid2dReleaseIPAddr(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 84 void OnHid2dGetRecommendChannel(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 85 void OnHid2dGetChannelListFor5G(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 86 void OnHid2dGetSelfWifiCfgInfo(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 87 void OnHid2dSetPeerWifiCfgInfo(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 88 void OnHid2dSetUpperScene(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 89 bool ReadWifiP2pServiceInfo(MessageParcel &data, WifiP2pServiceInfo &info); 90 bool ReadWifiP2pServiceRequest(MessageParcel &data, WifiP2pDevice &device, WifiP2pServiceRequest &request); 91 void WriteWifiP2pServiceInfo(MessageParcel &reply, const WifiP2pServiceInfo &info); 92 void ReadWifiP2pDeviceData(MessageParcel &data, WifiP2pDevice &device); 93 void WriteWifiP2pDeviceData(MessageParcel &reply, const WifiP2pDevice &device); 94 bool ReadWifiP2pGroupData(MessageParcel &data, WifiP2pGroupInfo &info); 95 void WriteWifiP2pGroupData(MessageParcel &reply, const WifiP2pGroupInfo &info); 96 void ReadWifiP2pConfigData(MessageParcel &data, WifiP2pConfig &config); 97 void OnQueryP2pLocalDevice(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 98 void OnDiscoverPeers(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 99 void OnDisableRandomMac(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 100 void OnCheckCanUseP2p(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 101 void OnHid2dIsWideBandwidthSupported( 102 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 103 104 private: 105 HandleFuncMap handleFuncMap; 106 std::mutex deathRecipientMutex; 107 sptr<IRemoteObject::DeathRecipient> deathRecipient_; 108 bool mSingleCallback; 109 }; 110 } // namespace Wifi 111 } // namespace OHOS 112 #endif