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