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 #include "wifi_device_stub.h"
17 #include "string_ex.h"
18 #include "wifi_logger.h"
19 #include "wifi_msg.h"
20 #include "wifi_device_callback_proxy.h"
21 #include "wifi_internal_event_dispatcher.h"
22 #include "wifi_device_death_recipient.h"
23 #include "wifi_common_util.h"
24 #include "wifi_common_def.h"
25 #include "wifi_manager_service_ipc_interface_code.h"
26 #include "wifi_watchdog_utils.h"
27
28 DEFINE_WIFILOG_LABEL("WifiDeviceStub");
29
30 namespace OHOS {
31 namespace Wifi {
32
33 constexpr int SIGNALARR_LENGTH = 6;
34
35 constexpr int MAX_MDM_RESTRICTED_SIZE = 200;
36
37 static std::map<int, std::string> g_HicollieStaMap = {
38 {static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_IS_WIFI_CONNECTED), "WIFI_SVR_CMD_IS_WIFI_CONNECTED"},
39 {static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_IS_WIFI_ACTIVE), "WIFI_SVR_CMD_IS_WIFI_ACTIVE"},
40 {static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_IS_METERED_HOTSPOT), "WIFI_SVR_CMD_IS_METERED_HOTSPOT"},
41 {static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_REGISTER_CALLBACK_CLIENT),
42 "WIFI_SVR_CMD_REGISTER_CALLBACK_CLIENT"},
43 {static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_SIGNAL_LEVEL), "WIFI_SVR_CMD_GET_SIGNAL_LEVEL"},
44 {static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_WIFI_DETAIL_STATE), "WIFI_SVR_CMD_GET_WIFI_DETAIL_STATE"},
45 };
46
WifiDeviceStub()47 WifiDeviceStub::WifiDeviceStub() : mSingleCallback(false)
48 {
49 WIFI_LOGI("enter WifiDeviceStub!");
50 InitHandleMap();
51 deathRecipient_ = nullptr;
52 }
53
WifiDeviceStub(int instId)54 WifiDeviceStub::WifiDeviceStub(int instId) : mSingleCallback(false), m_instId(instId)
55 {
56 WIFI_LOGI("enter WifiDeviceStub!");
57 InitHandleMap();
58 deathRecipient_ = nullptr;
59 }
60
~WifiDeviceStub()61 WifiDeviceStub::~WifiDeviceStub()
62 {
63 WIFI_LOGI("enter ~WifiDeviceStub!");
64 deathRecipient_ = nullptr;
65 }
66
InitHandleMapEx()67 void WifiDeviceStub::InitHandleMapEx()
68 {
69 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_SIGNAL_LEVEL)] = [this](uint32_t code,
70 MessageParcel &data, MessageParcel &reply) { OnGetSignalLevel(code, data, reply); };
71 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_SUPPORTED_FEATURES)] = [this](uint32_t code,
72 MessageParcel &data, MessageParcel &reply) { OnGetSupportedFeatures(code, data, reply); };
73 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_DHCP_IPV6INFO)] = [this](uint32_t code,
74 MessageParcel &data, MessageParcel &reply) { OnGetIpV6Info(code, data, reply); };
75 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_DERVICE_MAC_ADD)] = [this](uint32_t code,
76 MessageParcel &data, MessageParcel &reply) { OnGetDeviceMacAdd(code, data, reply); };
77 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_IS_WIFI_CONNECTED)] = [this](uint32_t code,
78 MessageParcel &data, MessageParcel &reply) { OnIsWifiConnected(code, data, reply); };
79 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_LOW_LATENCY_MODE)] = [this](uint32_t code,
80 MessageParcel &data, MessageParcel &reply) { OnSetLowLatencyMode(code, data, reply); };
81 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_REMOVE_CANDIDATE_CONFIG)] = [this](uint32_t code,
82 MessageParcel &data, MessageParcel &reply) { OnRemoveCandidateConfig(code, data, reply); };
83 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_BANDTYPE_SUPPORTED)] = [this](uint32_t code,
84 MessageParcel &data, MessageParcel &reply) { OnIsBandTypeSupported(code, data, reply); };
85 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_5G_CHANNELLIST)] = [this](uint32_t code,
86 MessageParcel &data, MessageParcel &reply) { OnGet5GHzChannelList(code, data, reply); };
87 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_DISCONNECTED_REASON)] = [this](uint32_t code,
88 MessageParcel &data, MessageParcel &reply) { OnGetDisconnectedReason(code, data, reply); };
89 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_FROZEN_APP)] = [this](uint32_t code,
90 MessageParcel &data, MessageParcel &reply) { OnSetFrozenApp(code, data, reply); };
91 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_RESET_ALL_FROZEN_APP)] = [this](uint32_t code,
92 MessageParcel &data, MessageParcel &reply) { OnResetAllFrozenApp(code, data, reply); };
93 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_DISABLE_AUTO_JOIN)] = [this](uint32_t code,
94 MessageParcel &data, MessageParcel &reply) { OnDisableAutoJoin(code, data, reply); };
95 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_ENABLE_AUTO_JOIN)] = [this](uint32_t code,
96 MessageParcel &data, MessageParcel &reply) { OnEnableAutoJoin(code, data, reply); };
97 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_START_PORTAL_CERTIF)] = [this](uint32_t code,
98 MessageParcel &data, MessageParcel &reply) { OnStartPortalCertification(code, data, reply); };
99 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_DEVICE_CONFIG_CHANGE)] = [this](
100 uint32_t code, MessageParcel &data, MessageParcel &reply) { OnGetChangeDeviceConfig(code, data, reply); };
101 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_IS_SET_FACTORY_RESET)] = [this](uint32_t code,
102 MessageParcel &data, MessageParcel &reply) { OnFactoryReset(code, data, reply); };
103 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_LIMIT_SPEED)] = [this](uint32_t code,
104 MessageParcel &data, MessageParcel &reply) { OnLimitSpeed(code, data, reply); };
105 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_IS_HILINK_CONNECT)] = [this](uint32_t code,
106 MessageParcel &data, MessageParcel &reply) { OnEnableHiLinkHandshake(code, data, reply); };
107 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_ENABLE_SEMI_WIFI)] = [this](uint32_t code,
108 MessageParcel &data, MessageParcel &reply) { OnEnableSemiWifi(code, data, reply); };
109 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_WIFI_DETAIL_STATE)] = [this](uint32_t code,
110 MessageParcel &data, MessageParcel &reply) { OnGetWifiDetailState(code, data, reply); };
111 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_SATELLITE_STATE)] = [this](uint32_t code,
112 MessageParcel &data, MessageParcel &reply) { OnSetSatelliteState(code, data, reply); };
113 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_LOW_TX_POWER)] = [this](uint32_t code,
114 MessageParcel &data, MessageParcel &reply) { OnSetLowTxPower(code, data, reply); };
115 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_TX_POWER)] = [this](uint32_t code,
116 MessageParcel &data, MessageParcel &reply) { OnSetTxPower(code, data, reply); };
117 return;
118 }
119
InitHandleMapEx2()120 void WifiDeviceStub::InitHandleMapEx2()
121 {
122 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_START_ROAM_TO_NETWORK)] = [this](uint32_t code,
123 MessageParcel &data, MessageParcel &reply) { OnStartRoamToNetwork(code, data, reply); };
124 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_START_CONNECT_TO_USER_SELECT_NETWORK)] =
125 [this](uint32_t code, MessageParcel &data, MessageParcel &reply) {
126 OnStartConnectToUserSelectNetwork(code, data, reply);
127 };
128 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_DEVICE_CONFIG)] = [this](uint32_t code,
129 MessageParcel &data, MessageParcel &reply) { OnGetDeviceConfig(code, data, reply); };
130 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_DPI_MARK_RULE)] = [this](uint32_t code,
131 MessageParcel &data, MessageParcel &reply) { OnSetDpiMarkRule(code, data, reply); };
132 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_IS_FEATURE_SUPPORTED)] = [this](uint32_t code,
133 MessageParcel &data, MessageParcel &reply) { OnIsFeatureSupported(code, data, reply); };
134 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_NET_CONTROL_INFO)] = [this](uint32_t code,
135 MessageParcel &data, MessageParcel &reply) { OnReceiveNetworkControlInfo(code, data, reply); };
136 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_NETWORK_LAG_INFO)] = [this](uint32_t code,
137 MessageParcel &data, MessageParcel &reply) { OnUpdateNetworkLagInfo(code, data, reply); };
138 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_FETCH_SIGNALINFO_VOWIFI)] = [this](uint32_t code,
139 MessageParcel &data, MessageParcel &reply) { OnFetchWifiSignalInfoForVoWiFi(code, data, reply); };
140 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_IS_SUPPORT_VOWIFI_DETECT)] = [this]
141 (uint32_t code, MessageParcel &data, MessageParcel &reply) { OnIsSupportVoWifiDetect(code, data, reply); };
142 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_VOWIFI_DETECT_MODE)] = [this](uint32_t code,
143 MessageParcel &data, MessageParcel &reply) { OnSetVoWifiDetectMode(code, data, reply); };
144 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_VOWIFI_DETECT_MODE)] = [this](uint32_t code,
145 MessageParcel &data, MessageParcel &reply) { OnGetVoWifiDetectMode(code, data, reply); };
146 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_VOWIFI_DETECT_PERIOD)] = [this]
147 (uint32_t code, MessageParcel &data, MessageParcel &reply) { OnSetVoWifiDetectPeriod(code, data, reply); };
148 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_VOWIFI_DETECT_PERIOD)] = [this]
149 (uint32_t code, MessageParcel &data, MessageParcel &reply) { OnGetVoWifiDetectPeriod(code, data, reply); };
150 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_SIGNALPOLL_INFO_ARRAY)] = [this]
151 (uint32_t code, MessageParcel &data, MessageParcel &reply) { OnGetSignalPollInfoArray(code, data, reply); };
152 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_MULTI_LINKED_INFO)] = [this]
153 (uint32_t code, MessageParcel &data, MessageParcel &reply) { OnGetMultiLinkedInfo(code, data, reply); };
154 }
155
InitHandleMap()156 void WifiDeviceStub::InitHandleMap()
157 {
158 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_ENABLE_WIFI)] = [this](uint32_t code,
159 MessageParcel &data, MessageParcel &reply) { OnEnableWifi(code, data, reply); };
160 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_DISABLE_WIFI)] = [this](uint32_t code,
161 MessageParcel &data, MessageParcel &reply) { OnDisableWifi(code, data, reply); };
162 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_INIT_WIFI_PROTECT)] = [this](uint32_t code,
163 MessageParcel &data, MessageParcel &reply) { OnInitWifiProtect(code, data, reply); };
164 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_WIFI_PROTECT)] = [this](uint32_t code,
165 MessageParcel &data, MessageParcel &reply) { OnGetWifiProtectRef(code, data, reply); };
166 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_PUT_WIFI_PROTECT)] = [this](uint32_t code,
167 MessageParcel &data, MessageParcel &reply) { OnPutWifiProtectRef(code, data, reply); };
168 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_IS_HELD_WIFI_PROTECT)] = [this](uint32_t code,
169 MessageParcel &data, MessageParcel &reply) { OnIsHeldWifiProtectRef(code, data, reply); };
170 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_ADD_DEVICE_CONFIG)] = [this](uint32_t code,
171 MessageParcel &data, MessageParcel &reply) { OnAddDeviceConfig(code, data, reply); };
172 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_WIFI_ACCESS_LIST)] = [this](uint32_t code,
173 MessageParcel &data, MessageParcel &reply) { OnSetWifiRestrictedList(code, data, reply); };
174 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_UPDATE_DEVICE_CONFIG)] = [this](uint32_t code,
175 MessageParcel &data, MessageParcel &reply) { OnUpdateDeviceConfig(code, data, reply); };
176 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_REMOVE_DEVICE_CONFIG)] = [this](uint32_t code,
177 MessageParcel &data, MessageParcel &reply) { OnRemoveDevice(code, data, reply); };
178 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_REMOVE_ALL_DEVICE_CONFIG)] =
179 [this](uint32_t code, MessageParcel &data, MessageParcel &reply) { OnRemoveAllDevice(code, data, reply); };
180 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_DEVICE_CONFIGS)] = [this](uint32_t code,
181 MessageParcel &data, MessageParcel &reply) { OnGetDeviceConfigs(code, data, reply); };
182 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_ENABLE_DEVICE)] = [this](uint32_t code,
183 MessageParcel &data, MessageParcel &reply) { OnEnableDeviceConfig(code, data, reply); };
184 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_DISABLE_DEVICE)] = [this](uint32_t code,
185 MessageParcel &data, MessageParcel &reply) { OnDisableDeviceConfig(code, data, reply); };
186 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_ALLOW_AUTO_CONNECT)] = [this](uint32_t code,
187 MessageParcel &data, MessageParcel &reply) { OnAllowAutoConnect(code, data, reply); };
188 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_CONNECT_TO)] = [this](uint32_t code,
189 MessageParcel &data, MessageParcel &reply) { OnConnectTo(code, data, reply); };
190 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_CONNECT2_TO)] = [this](uint32_t code,
191 MessageParcel &data, MessageParcel &reply) { OnConnect2To(code, data, reply); };
192 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_RECONNECT)] = [this](uint32_t code,
193 MessageParcel &data, MessageParcel &reply) { OnReConnect(code, data, reply); };
194 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_REASSOCIATE)] = [this](uint32_t code,
195 MessageParcel &data, MessageParcel &reply) { OnReAssociate(code, data, reply); };
196 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_DISCONNECT)] = [this](uint32_t code,
197 MessageParcel &data, MessageParcel &reply) { OnDisconnect(code, data, reply); };
198 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_START_WPS)] = [this](uint32_t code,
199 MessageParcel &data, MessageParcel &reply) { OnStartWps(code, data, reply); };
200 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_CANCEL_WPS)] = [this](uint32_t code,
201 MessageParcel &data, MessageParcel &reply) { OnCancelWps(code, data, reply); };
202 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_IS_WIFI_ACTIVE)] = [this](uint32_t code,
203 MessageParcel &data, MessageParcel &reply) { OnIsWifiActive(code, data, reply); };
204 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_WIFI_STATE)] = [this](uint32_t code,
205 MessageParcel &data, MessageParcel &reply) { OnGetWifiState(code, data, reply); };
206 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_IS_METERED_HOTSPOT)] = [this](uint32_t code,
207 MessageParcel &data, MessageParcel &reply) { OnIsMeteredHotspot(code, data, reply); };
208 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_LINKED_INFO)] = [this](uint32_t code,
209 MessageParcel &data, MessageParcel &reply) { OnGetLinkedInfo(code, data, reply); };
210 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_DHCP_INFO)] = [this](uint32_t code,
211 MessageParcel &data, MessageParcel &reply) { OnGetIpInfo(code, data, reply); };
212 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_COUNTRY_CODE)] = [this](uint32_t code,
213 MessageParcel &data, MessageParcel &reply) { OnSetCountryCode(code, data, reply); };
214 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_COUNTRY_CODE)] = [this](uint32_t code,
215 MessageParcel &data, MessageParcel &reply) { OnGetCountryCode(code, data, reply); };
216 handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_REGISTER_CALLBACK_CLIENT)] =
217 [this](uint32_t code, MessageParcel &data, MessageParcel &reply) { OnRegisterCallBack(code, data, reply); };
218 InitHandleMapEx();
219 InitHandleMapEx2();
220 return;
221 }
222
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)223 int WifiDeviceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
224 {
225 if (data.ReadInterfaceToken() != GetDescriptor()) {
226 WIFI_LOGE("Sta stub token verification error: %{public}d", code);
227 return WIFI_OPT_FAILED;
228 }
229
230 WIFI_LOGD("%{public}s, code: %{public}u, uid: %{public}d, pid: %{public}d",
231 __func__, code, GetCallingUid(), GetCallingPid());
232 HandleFuncMap::iterator iter = handleFuncMap.find(code);
233 if (iter == handleFuncMap.end()) {
234 WIFI_LOGI("not find function to deal, code %{public}u", code);
235 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
236 } else {
237 int exception = data.ReadInt32();
238 if (exception) {
239 return WIFI_OPT_FAILED;
240 }
241 std::map<int, std::string>::const_iterator itCollieId = g_HicollieStaMap.find(code);
242 if (itCollieId != g_HicollieStaMap.end()) {
243 int idTimer = 0;
244 idTimer = WifiWatchDogUtils::GetInstance()->StartWatchDogForFunc(itCollieId->second);
245 WIFI_LOGI("SetTimer id: %{public}d, name: %{public}s.", idTimer, itCollieId->second.c_str());
246 (iter->second)(code, data, reply);
247 WifiWatchDogUtils::GetInstance()->StopWatchDogForFunc(itCollieId->second, idTimer);
248 } else {
249 (iter->second)(code, data, reply);
250 }
251 }
252 return 0;
253 }
254
255
OnEnableWifi(uint32_t code,MessageParcel & data,MessageParcel & reply)256 void WifiDeviceStub::OnEnableWifi(uint32_t code, MessageParcel &data, MessageParcel &reply)
257 {
258 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
259 #ifdef DYNAMIC_UNLOAD_SA
260 StopUnloadStaTimer();
261 #endif
262 ErrCode ret = EnableWifi();
263 reply.WriteInt32(0);
264 reply.WriteInt32(ret);
265
266 return;
267 }
268
OnDisableWifi(uint32_t code,MessageParcel & data,MessageParcel & reply)269 void WifiDeviceStub::OnDisableWifi(uint32_t code, MessageParcel &data, MessageParcel &reply)
270 {
271 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
272 ErrCode ret = DisableWifi();
273 reply.WriteInt32(0);
274 reply.WriteInt32(ret);
275 return;
276 }
277
OnInitWifiProtect(uint32_t code,MessageParcel & data,MessageParcel & reply)278 void WifiDeviceStub::OnInitWifiProtect(uint32_t code, MessageParcel &data, MessageParcel &reply)
279 {
280 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
281 ErrCode ret = WIFI_OPT_FAILED;
282 WifiProtectType protectType = (WifiProtectType)data.ReadInt32();
283 const char *readStr = data.ReadCString();
284 if (readStr == nullptr) {
285 ret = WIFI_OPT_INVALID_PARAM;
286 } else {
287 std::string protectName = readStr;
288 ret = InitWifiProtect(protectType, protectName);
289 }
290 reply.WriteInt32(0);
291 reply.WriteInt32(ret);
292 return;
293 }
294
OnGetWifiProtectRef(uint32_t code,MessageParcel & data,MessageParcel & reply)295 void WifiDeviceStub::OnGetWifiProtectRef(uint32_t code, MessageParcel &data, MessageParcel &reply)
296 {
297 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
298 ErrCode ret = WIFI_OPT_FAILED;
299 WifiProtectMode protectMode = (WifiProtectMode)data.ReadInt32();
300 const char *readStr = data.ReadCString();
301 if (readStr == nullptr) {
302 ret = WIFI_OPT_INVALID_PARAM;
303 } else {
304 std::string protectName = readStr;
305 ret = GetWifiProtectRef(protectMode, protectName);
306 }
307 reply.WriteInt32(0);
308 reply.WriteInt32(ret);
309 return;
310 }
311
OnPutWifiProtectRef(uint32_t code,MessageParcel & data,MessageParcel & reply)312 void WifiDeviceStub::OnPutWifiProtectRef(uint32_t code, MessageParcel &data, MessageParcel &reply)
313 {
314 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
315 ErrCode ret = WIFI_OPT_FAILED;
316 const char *readStr = data.ReadCString();
317 if (readStr == nullptr) {
318 ret = WIFI_OPT_INVALID_PARAM;
319 } else {
320 std::string protectName = readStr;
321 ret = PutWifiProtectRef(protectName);
322 }
323 reply.WriteInt32(0);
324 reply.WriteInt32(ret);
325 return;
326 }
327
OnIsHeldWifiProtectRef(uint32_t code,MessageParcel & data,MessageParcel & reply)328 void WifiDeviceStub::OnIsHeldWifiProtectRef(uint32_t code, MessageParcel &data, MessageParcel &reply)
329 {
330 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
331 ErrCode ret = WIFI_OPT_FAILED;
332 const char *readStr = data.ReadCString();
333 bool isHoldProtect = false;
334 if (readStr == nullptr) {
335 ret = WIFI_OPT_INVALID_PARAM;
336 } else {
337 std::string protectName = readStr;
338 ret = IsHeldWifiProtectRef(protectName, isHoldProtect);
339 }
340 reply.WriteInt32(0);
341 reply.WriteInt32(ret);
342 if (ret == WIFI_OPT_SUCCESS) {
343 reply.WriteBool(isHoldProtect);
344 }
345 return;
346 }
347
OnAddDeviceConfig(uint32_t code,MessageParcel & data,MessageParcel & reply)348 void WifiDeviceStub::OnAddDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply)
349 {
350 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
351 bool isCandidate = data.ReadBool();
352 WifiDeviceConfig config;
353 ReadWifiDeviceConfig(data, config);
354
355 int result = INVALID_NETWORK_ID;
356 ErrCode ret = AddDeviceConfig(config, result, isCandidate);
357
358 reply.WriteInt32(0);
359 reply.WriteInt32(ret);
360 if (ret == WIFI_OPT_SUCCESS) {
361 reply.WriteInt32(result);
362 }
363
364 return;
365 }
366
OnSetWifiRestrictedList(uint32_t code,MessageParcel & data,MessageParcel & reply)367 void WifiDeviceStub::OnSetWifiRestrictedList(uint32_t code, MessageParcel &data, MessageParcel &reply)
368 {
369 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
370 int size = data.ReadInt32();
371 ErrCode ret = WIFI_OPT_FAILED;
372 int result = INVALID_NETWORK_ID;
373 if (size > MAX_MDM_RESTRICTED_SIZE) {
374 ret = WIFI_OPT_MDM_OUT_MAX_NUM;
375 } else {
376 std::vector<WifiRestrictedInfo> wifiList;
377 for (int i = 0; i < size; i++) {
378 WifiRestrictedInfo info;
379 info.ssid = data.ReadString();
380 info.bssid = data.ReadString();
381 info.uid = data.ReadInt32();
382 info.wifiRestrictedType = static_cast<WifiRestrictedType>(data.ReadInt32());
383 wifiList.push_back(info);
384 }
385 ret = SetWifiRestrictedList(wifiList);
386 }
387 reply.WriteInt32(0);
388 reply.WriteInt32(ret);
389 if (ret == WIFI_OPT_SUCCESS) {
390 reply.WriteInt32(result);
391 }
392 return;
393 }
394
OnUpdateDeviceConfig(uint32_t code,MessageParcel & data,MessageParcel & reply)395 void WifiDeviceStub::OnUpdateDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply)
396 {
397 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
398 WifiDeviceConfig config;
399 ReadWifiDeviceConfig(data, config);
400 int result = INVALID_NETWORK_ID;
401 ErrCode ret = UpdateDeviceConfig(config, result);
402 reply.WriteInt32(0);
403 reply.WriteInt32(ret);
404 if (ret == WIFI_OPT_SUCCESS) {
405 reply.WriteInt32(result);
406 }
407 return;
408 }
409
ReadEapConfig(MessageParcel & data,WifiEapConfig & wifiEapConfig)410 void WifiDeviceStub::ReadEapConfig(MessageParcel &data, WifiEapConfig &wifiEapConfig)
411 {
412 wifiEapConfig.eap = data.ReadString();
413 wifiEapConfig.phase2Method = Phase2Method(data.ReadInt32());
414 wifiEapConfig.identity = data.ReadString();
415 wifiEapConfig.anonymousIdentity = data.ReadString();
416 wifiEapConfig.password = data.ReadString();
417
418 wifiEapConfig.caCertPath = data.ReadString();
419 wifiEapConfig.caCertAlias = data.ReadString();
420 data.ReadUInt8Vector(&wifiEapConfig.certEntry);
421
422 wifiEapConfig.clientCert = data.ReadString();
423 if (strcpy_s(wifiEapConfig.certPassword, sizeof(wifiEapConfig.certPassword),
424 data.ReadString().c_str()) != EOK) {
425 WIFI_LOGE("%{public}s: failed to copy", __func__);
426 }
427 wifiEapConfig.privateKey = data.ReadString();
428
429 wifiEapConfig.altSubjectMatch = data.ReadString();
430 wifiEapConfig.domainSuffixMatch = data.ReadString();
431 wifiEapConfig.realm = data.ReadString();
432 wifiEapConfig.plmn = data.ReadString();
433 wifiEapConfig.eapSubId = data.ReadInt32();
434 }
435
ReadWifiDeviceConfig(MessageParcel & data,WifiDeviceConfig & config)436 void WifiDeviceStub::ReadWifiDeviceConfig(MessageParcel &data, WifiDeviceConfig &config)
437 {
438 config.networkId = data.ReadInt32();
439 config.bssid = data.ReadString();
440 config.bssidType = data.ReadInt32();
441 config.ssid = data.ReadString();
442 config.band = data.ReadInt32();
443 config.channel = data.ReadInt32();
444 config.frequency = data.ReadInt32();
445 config.level = data.ReadInt32();
446 config.isPasspoint = data.ReadBool();
447 config.isEphemeral = data.ReadBool();
448 config.preSharedKey = data.ReadString();
449 config.keyMgmt = data.ReadString();
450 for (int i = 0; i < WEPKEYS_SIZE; i++) {
451 config.wepKeys[i] = data.ReadString();
452 }
453 config.wepTxKeyIndex = data.ReadInt32();
454 config.priority = data.ReadInt32();
455 config.hiddenSSID = data.ReadBool();
456 config.wifiIpConfig.assignMethod = AssignIpMethod(data.ReadInt32());
457 ReadIpAddress(data, config.wifiIpConfig.staticIpAddress.ipAddress.address);
458 config.wifiIpConfig.staticIpAddress.ipAddress.prefixLength = data.ReadInt32();
459 config.wifiIpConfig.staticIpAddress.ipAddress.flags = data.ReadInt32();
460 config.wifiIpConfig.staticIpAddress.ipAddress.scope = data.ReadInt32();
461 ReadIpAddress(data, config.wifiIpConfig.staticIpAddress.gateway);
462 ReadIpAddress(data, config.wifiIpConfig.staticIpAddress.dnsServer1);
463 ReadIpAddress(data, config.wifiIpConfig.staticIpAddress.dnsServer2);
464 config.wifiIpConfig.staticIpAddress.domains = data.ReadString();
465 ReadEapConfig(data, config.wifiEapConfig);
466 config.wifiProxyconfig.configureMethod = ConfigureProxyMethod(data.ReadInt32());
467 config.wifiProxyconfig.autoProxyConfig.pacWebAddress = data.ReadString();
468 config.wifiProxyconfig.manualProxyConfig.serverHostName = data.ReadString();
469 config.wifiProxyconfig.manualProxyConfig.serverPort = data.ReadInt32();
470 config.wifiProxyconfig.manualProxyConfig.exclusionObjectList = data.ReadString();
471 config.wifiPrivacySetting = WifiPrivacyConfig(data.ReadInt32());
472 config.callProcessName = data.ReadString();
473 config.ancoCallProcessName = data.ReadString();
474 config.uid = data.ReadInt32();
475 config.wifiWapiConfig.wapiPskType = data.ReadInt32();
476 config.wifiWapiConfig.wapiAsCertData = data.ReadString();
477 config.wifiWapiConfig.wapiUserCertData = data.ReadString();
478 return;
479 }
480
ReadIpAddress(MessageParcel & data,WifiIpAddress & address)481 void WifiDeviceStub::ReadIpAddress(MessageParcel &data, WifiIpAddress &address)
482 {
483 constexpr int MAX_LIMIT_SIZE = 1024;
484 address.family = data.ReadInt32();
485 address.addressIpv4 = static_cast<uint32_t>(data.ReadInt32());
486 int size = data.ReadInt32();
487 if (size > MAX_LIMIT_SIZE) {
488 WIFI_LOGE("Read ip address parameter error: %{public}d", size);
489 return;
490 }
491 for (int i = 0; i < size; i++) {
492 address.addressIpv6.push_back(data.ReadInt8());
493 }
494 return;
495 }
496
WriteEapConfig(MessageParcel & reply,const WifiEapConfig & wifiEapConfig)497 void WifiDeviceStub::WriteEapConfig(MessageParcel &reply, const WifiEapConfig &wifiEapConfig)
498 {
499 reply.WriteString(wifiEapConfig.eap);
500 reply.WriteInt32(static_cast<int>(wifiEapConfig.phase2Method));
501 reply.WriteString(wifiEapConfig.identity);
502 reply.WriteString(wifiEapConfig.anonymousIdentity);
503 reply.WriteString(wifiEapConfig.password);
504
505 reply.WriteString(wifiEapConfig.caCertPath);
506 reply.WriteString(wifiEapConfig.caCertAlias);
507 reply.WriteUInt8Vector(wifiEapConfig.certEntry);
508
509 reply.WriteString(wifiEapConfig.clientCert);
510 reply.WriteString(std::string(wifiEapConfig.certPassword));
511 reply.WriteString(wifiEapConfig.privateKey);
512
513 reply.WriteString(wifiEapConfig.altSubjectMatch);
514 reply.WriteString(wifiEapConfig.domainSuffixMatch);
515 reply.WriteString(wifiEapConfig.realm);
516 reply.WriteString(wifiEapConfig.plmn);
517 reply.WriteInt32(wifiEapConfig.eapSubId);
518 }
519
BigDataWriteEapConfig(const WifiEapConfig & wifiEapConfig,std::stringstream & bigDataStream)520 void WifiDeviceStub::BigDataWriteEapConfig(const WifiEapConfig &wifiEapConfig, std::stringstream &bigDataStream)
521 {
522 bigDataStream << StringToHex(wifiEapConfig.eap) << ";";
523 bigDataStream << static_cast<int>(wifiEapConfig.phase2Method) << ";";
524 bigDataStream << StringToHex(wifiEapConfig.identity) << ";";
525 bigDataStream << StringToHex(wifiEapConfig.anonymousIdentity) << ";";
526 bigDataStream << StringToHex(wifiEapConfig.password) << ";";
527
528 bigDataStream << StringToHex(wifiEapConfig.caCertPath) << ";";
529 bigDataStream << StringToHex(wifiEapConfig.caCertAlias) << ";";
530
531 bigDataStream << StringToHex(wifiEapConfig.clientCert) << ";";
532 bigDataStream << StringToHex(wifiEapConfig.privateKey) << ";";
533
534 bigDataStream << StringToHex(wifiEapConfig.altSubjectMatch) << ";";
535 bigDataStream << StringToHex(wifiEapConfig.domainSuffixMatch) << ";";
536 bigDataStream << StringToHex(wifiEapConfig.realm) << ";";
537 bigDataStream << StringToHex(wifiEapConfig.plmn) << ";";
538 bigDataStream << wifiEapConfig.eapSubId << ";";
539 }
540
WriteWifiDeviceConfig(MessageParcel & reply,const WifiDeviceConfig & config)541 void WifiDeviceStub::WriteWifiDeviceConfig(MessageParcel &reply, const WifiDeviceConfig &config)
542 {
543 reply.WriteInt32(config.networkId);
544 reply.WriteString(config.bssid);
545 reply.WriteString(config.userSelectBssid);
546 reply.WriteInt32(config.bssidType);
547 reply.WriteString(config.ssid);
548 reply.WriteInt32(config.band);
549 reply.WriteInt32(config.channel);
550 reply.WriteInt32(config.frequency);
551 reply.WriteInt32(config.level);
552 reply.WriteBool(config.isPasspoint);
553 reply.WriteBool(config.isEphemeral);
554 reply.WriteString(config.preSharedKey);
555 reply.WriteString(config.keyMgmt);
556 for (int j = 0; j < WEPKEYS_SIZE; j++) {
557 reply.WriteString(config.wepKeys[j]);
558 }
559 reply.WriteInt32(config.wepTxKeyIndex);
560 reply.WriteInt32(config.priority);
561 reply.WriteBool(config.hiddenSSID);
562 reply.WriteInt32((int)config.wifiIpConfig.assignMethod);
563 WriteIpAddress(reply, config.wifiIpConfig.staticIpAddress.ipAddress.address);
564 reply.WriteInt32(config.wifiIpConfig.staticIpAddress.ipAddress.prefixLength);
565 reply.WriteInt32(config.wifiIpConfig.staticIpAddress.ipAddress.flags);
566 reply.WriteInt32(config.wifiIpConfig.staticIpAddress.ipAddress.scope);
567 WriteIpAddress(reply, config.wifiIpConfig.staticIpAddress.gateway);
568 WriteIpAddress(reply, config.wifiIpConfig.staticIpAddress.dnsServer1);
569 WriteIpAddress(reply, config.wifiIpConfig.staticIpAddress.dnsServer2);
570 reply.WriteString(config.wifiIpConfig.staticIpAddress.domains);
571 WriteEapConfig(reply, config.wifiEapConfig);
572 WriteWifiDeviceConfigProxyExtral(reply, config);
573 reply.WriteInt32((int)config.wifiPrivacySetting);
574 reply.WriteInt32(config.uid);
575 reply.WriteString(config.callProcessName);
576 reply.WriteString(config.ancoCallProcessName);
577 reply.WriteInt32(config.wifiWapiConfig.wapiPskType);
578 reply.WriteString(config.wifiWapiConfig.wapiAsCertData);
579 reply.WriteString(config.wifiWapiConfig.wapiUserCertData);
580 reply.WriteInt32((int)config.networkSelectionStatus.status);
581 reply.WriteInt32((int)config.networkSelectionStatus.networkSelectionDisableReason);
582 reply.WriteBool(config.networkSelectionStatus.seenInLastQualifiedNetworkSelection);
583 reply.WriteBool(config.isPortal);
584 reply.WriteBool(config.noInternetAccess);
585 reply.WriteBool(config.isAllowAutoConnect);
586 reply.WriteBool(config.isSecureWifi);
587 return;
588 }
589
WriteWifiDeviceConfigProxyExtral(MessageParcel & reply,const WifiDeviceConfig & config)590 void WifiDeviceStub::WriteWifiDeviceConfigProxyExtral(MessageParcel &reply, const WifiDeviceConfig &config)
591 {
592 reply.WriteInt32((int)config.wifiProxyconfig.configureMethod);
593 reply.WriteString(config.wifiProxyconfig.autoProxyConfig.pacWebAddress);
594 reply.WriteString(config.wifiProxyconfig.manualProxyConfig.serverHostName);
595 reply.WriteInt32(config.wifiProxyconfig.manualProxyConfig.serverPort);
596 reply.WriteString(config.wifiProxyconfig.manualProxyConfig.exclusionObjectList);
597 }
598
WriteIpAddress(MessageParcel & reply,const WifiIpAddress & address)599 void WifiDeviceStub::WriteIpAddress(MessageParcel &reply, const WifiIpAddress &address)
600 {
601 reply.WriteInt32(address.family);
602 reply.WriteInt32(address.addressIpv4);
603 int size = static_cast<int>(address.addressIpv6.size());
604 reply.WriteInt32(size);
605 for (int i = 0; i < size; i++) {
606 reply.WriteInt8(address.addressIpv6[i]);
607 }
608
609 return;
610 }
611
BigDataWriteIpAddress(const WifiIpAddress & address,std::stringstream & bigDataStream)612 void WifiDeviceStub::BigDataWriteIpAddress(const WifiIpAddress &address, std::stringstream &bigDataStream)
613 {
614 bigDataStream << address.family << ";";
615 bigDataStream << address.addressIpv4 << ";";
616 int size = static_cast<int>(address.addressIpv6.size());
617 bigDataStream << size << ";";
618 for (int i = 0; i < size; i++) {
619 bigDataStream << address.addressIpv6[i] << ";";
620 }
621
622 return;
623 }
624
OnRemoveDevice(uint32_t code,MessageParcel & data,MessageParcel & reply)625 void WifiDeviceStub::OnRemoveDevice(uint32_t code, MessageParcel &data, MessageParcel &reply)
626 {
627 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
628 int networkId = data.ReadInt32();
629 ErrCode ret = RemoveDevice(networkId);
630 reply.WriteInt32(0);
631 reply.WriteInt32(ret);
632
633 return;
634 }
635
OnRemoveAllDevice(uint32_t code,MessageParcel & data,MessageParcel & reply)636 void WifiDeviceStub::OnRemoveAllDevice(uint32_t code, MessageParcel &data, MessageParcel &reply)
637 {
638 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
639 ErrCode ret = RemoveAllDevice();
640 reply.WriteInt32(0);
641 reply.WriteInt32(ret);
642
643 return;
644 }
645
SendDeviceConfig(int contentSize,std::vector<WifiDeviceConfig> & result,MessageParcel & reply)646 void WifiDeviceStub::SendDeviceConfig(int contentSize, std::vector<WifiDeviceConfig> &result, MessageParcel &reply)
647 {
648 WIFI_LOGI("%{public}s, contentSize: %{public}d", __FUNCTION__, contentSize);
649 std::vector<uint32_t> allSize;
650 if (contentSize == 0) {
651 reply.WriteInt32(WIFI_OPT_SUCCESS);
652 reply.WriteUInt32Vector(allSize);
653 return;
654 }
655 std::string name = "deviceconfigs";
656 int32_t ashmemSize = 1000; // add buff for max 1000 device config
657 for (int32_t i = 0; i < contentSize; ++i) {
658 MessageParcel outParcel;
659 WriteWifiDeviceConfig(outParcel, result[i]);
660 ashmemSize += static_cast<int>(outParcel.GetDataSize());
661 }
662 sptr<Ashmem> ashmem = Ashmem::CreateAshmem(name.c_str(), ashmemSize);
663 if (ashmem == nullptr || !ashmem->MapReadAndWriteAshmem()) {
664 reply.WriteInt32(WIFI_OPT_FAILED);
665 if (ashmem != nullptr) {
666 ashmem->UnmapAshmem();
667 ashmem->CloseAshmem();
668 }
669 WIFI_LOGE("%{public}s ashmem create fail", __FUNCTION__);
670 return;
671 }
672 int offset = 0;
673 for (int32_t i = 0; i < contentSize; ++i) {
674 MessageParcel outParcel;
675 WriteWifiDeviceConfig(outParcel, result[i]);
676 int dataSize = static_cast<int>(outParcel.GetDataSize());
677 if (offset + dataSize > ashmemSize) {
678 WIFI_LOGW("%{public}s parcelLen over ssid: %{public}s, ashmemSize:%{public}d,"
679 "dataSize:%{public}d, offset:%{public}d", __FUNCTION__, SsidAnonymize(result[i].ssid).c_str(),
680 ashmemSize, dataSize, offset);
681 continue;
682 }
683 allSize.emplace_back(dataSize);
684 ashmem->WriteToAshmem(reinterpret_cast<void*>(outParcel.GetData()), dataSize, offset);
685 offset += dataSize;
686 }
687 reply.WriteInt32(WIFI_OPT_SUCCESS);
688 reply.WriteUInt32Vector(allSize);
689 reply.WriteAshmem(ashmem);
690 ashmem->UnmapAshmem();
691 ashmem->CloseAshmem();
692 }
693
694 constexpr uint32_t MAX_DEVICE_CONFIG_SIZE = 1024;
OnGetDeviceConfigs(uint32_t code,MessageParcel & data,MessageParcel & reply)695 void WifiDeviceStub::OnGetDeviceConfigs(uint32_t code, MessageParcel &data, MessageParcel &reply)
696 {
697 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
698 bool isCandidate = data.ReadBool();
699 std::vector<WifiDeviceConfig> result;
700 ErrCode ret = GetDeviceConfigs(result, isCandidate);
701 reply.WriteInt32(0);
702
703 if (ret != WIFI_OPT_SUCCESS) {
704 reply.WriteInt32(ret);
705 return;
706 }
707 uint32_t size = result.size();
708 if (size > MAX_DEVICE_CONFIG_SIZE) {
709 size = MAX_DEVICE_CONFIG_SIZE;
710 }
711 SendDeviceConfig(size, result, reply);
712 return;
713 }
714
OnEnableDeviceConfig(uint32_t code,MessageParcel & data,MessageParcel & reply)715 void WifiDeviceStub::OnEnableDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply)
716 {
717 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
718 int networkId = data.ReadInt32();
719 bool attemptEnable = data.ReadBool();
720 ErrCode ret = EnableDeviceConfig(networkId, attemptEnable);
721 reply.WriteInt32(0);
722 reply.WriteInt32(ret);
723
724 return;
725 }
726
OnDisableDeviceConfig(uint32_t code,MessageParcel & data,MessageParcel & reply)727 void WifiDeviceStub::OnDisableDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply)
728 {
729 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
730 int networkId = data.ReadInt32();
731 ErrCode ret = DisableDeviceConfig(networkId);
732 reply.WriteInt32(0);
733 reply.WriteInt32(ret);
734
735 return;
736 }
737
OnAllowAutoConnect(uint32_t code,MessageParcel & data,MessageParcel & reply)738 void WifiDeviceStub::OnAllowAutoConnect(uint32_t code, MessageParcel &data, MessageParcel &reply)
739 {
740 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
741 int32_t networkId = data.ReadInt32();
742 bool isAllowed = data.ReadBool();
743 ErrCode ret = AllowAutoConnect(networkId, isAllowed);
744 reply.WriteInt32(0);
745 reply.WriteInt32(ret);
746
747 return;
748 }
749
OnGetChangeDeviceConfig(uint32_t code,MessageParcel & data,MessageParcel & reply)750 void WifiDeviceStub::OnGetChangeDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply)
751 {
752 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
753 Wifi::ConfigChange value;
754 Wifi::WifiDeviceConfig config;
755 ErrCode ret = GetChangeDeviceConfig(value, config);
756 reply.WriteInt32(0);
757 reply.WriteInt32((int)value);
758 reply.WriteInt32(config.networkId);
759 reply.WriteString(config.ssid);
760 reply.WriteString(config.bssid);
761 reply.WriteString(config.callProcessName);
762 reply.WriteString(config.ancoCallProcessName);
763 reply.WriteString(config.keyMgmt);
764 reply.WriteInt32(ret);
765 return;
766 }
767
OnConnectTo(uint32_t code,MessageParcel & data,MessageParcel & reply)768 void WifiDeviceStub::OnConnectTo(uint32_t code, MessageParcel &data, MessageParcel &reply)
769 {
770 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
771 bool isCandidate = data.ReadBool();
772 int networkId = data.ReadInt32();
773 ErrCode ret = ConnectToNetwork(networkId, isCandidate);
774 reply.WriteInt32(0);
775 reply.WriteInt32(ret);
776
777 return;
778 }
779
OnConnect2To(uint32_t code,MessageParcel & data,MessageParcel & reply)780 void WifiDeviceStub::OnConnect2To(uint32_t code, MessageParcel &data, MessageParcel &reply)
781 {
782 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
783 WifiDeviceConfig config;
784 ReadWifiDeviceConfig(data, config);
785 ErrCode ret = ConnectToDevice(config);
786 reply.WriteInt32(0);
787 reply.WriteInt32(ret);
788
789 return;
790 }
791
OnStartRoamToNetwork(uint32_t code,MessageParcel & data,MessageParcel & reply)792 void WifiDeviceStub::OnStartRoamToNetwork(uint32_t code, MessageParcel &data, MessageParcel &reply)
793 {
794 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
795 int networkId = data.ReadInt32();
796 std::string bssid = data.ReadString();
797 bool isCandidate = data.ReadBool();
798 ErrCode ret = StartRoamToNetwork(networkId, bssid, isCandidate);
799 reply.WriteInt32(0);
800 reply.WriteInt32(ret);
801 return;
802 }
803
OnStartConnectToUserSelectNetwork(uint32_t code,MessageParcel & data,MessageParcel & reply)804 void WifiDeviceStub::OnStartConnectToUserSelectNetwork(uint32_t code, MessageParcel &data, MessageParcel &reply)
805 {
806 WIFI_LOGD("enter %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
807 int networkId = data.ReadInt32();
808 std::string bssid = data.ReadString();
809 bool isCandidate = data.ReadBool();
810 ErrCode ret = StartConnectToUserSelectNetwork(networkId, bssid, isCandidate);
811 reply.WriteInt32(0);
812 reply.WriteInt32(ret);
813 return;
814 }
815
OnIsWifiConnected(uint32_t code,MessageParcel & data,MessageParcel & reply)816 void WifiDeviceStub::OnIsWifiConnected(uint32_t code, MessageParcel &data, MessageParcel &reply)
817 {
818 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
819 bool isConnected = false;
820 ErrCode ret = IsConnected(isConnected);
821 reply.WriteInt32(0);
822 reply.WriteInt32(ret);
823 if (ret == WIFI_OPT_SUCCESS) {
824 reply.WriteBool(isConnected);
825 }
826 return;
827 }
828
OnReConnect(uint32_t code,MessageParcel & data,MessageParcel & reply)829 void WifiDeviceStub::OnReConnect(uint32_t code, MessageParcel &data, MessageParcel &reply)
830 {
831 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
832 ErrCode ret = ReConnect();
833 reply.WriteInt32(0);
834 reply.WriteInt32(ret);
835
836 return;
837 }
838
OnReAssociate(uint32_t code,MessageParcel & data,MessageParcel & reply)839 void WifiDeviceStub::OnReAssociate(uint32_t code, MessageParcel &data, MessageParcel &reply)
840 {
841 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
842 ErrCode ret = ReAssociate();
843 reply.WriteInt32(0);
844 reply.WriteInt32(ret);
845
846 return;
847 }
848
OnDisconnect(uint32_t code,MessageParcel & data,MessageParcel & reply)849 void WifiDeviceStub::OnDisconnect(uint32_t code, MessageParcel &data, MessageParcel &reply)
850 {
851 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
852 ErrCode ret = Disconnect();
853 reply.WriteInt32(0);
854 reply.WriteInt32(ret);
855
856 return;
857 }
858
OnStartWps(uint32_t code,MessageParcel & data,MessageParcel & reply)859 void WifiDeviceStub::OnStartWps(uint32_t code, MessageParcel &data, MessageParcel &reply)
860 {
861 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
862 ErrCode ret = WIFI_OPT_FAILED;
863 WpsConfig config;
864 config.setup = SetupMethod(data.ReadInt32());
865 const char *pinRead = data.ReadCString();
866 const char *bssidRead = data.ReadCString();
867 if (pinRead == nullptr || bssidRead == nullptr) {
868 ret = WIFI_OPT_INVALID_PARAM;
869 } else {
870 config.pin = pinRead;
871 config.bssid = bssidRead;
872 ret = StartWps(config);
873 }
874
875 reply.WriteInt32(0);
876 reply.WriteInt32(ret);
877
878 return;
879 }
880
OnCancelWps(uint32_t code,MessageParcel & data,MessageParcel & reply)881 void WifiDeviceStub::OnCancelWps(uint32_t code, MessageParcel &data, MessageParcel &reply)
882 {
883 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
884 ErrCode ret = CancelWps();
885 reply.WriteInt32(0);
886 reply.WriteInt32(ret);
887
888 return;
889 }
890
OnIsWifiActive(uint32_t code,MessageParcel & data,MessageParcel & reply)891 void WifiDeviceStub::OnIsWifiActive(uint32_t code, MessageParcel &data, MessageParcel &reply)
892 {
893 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
894 bool bActive = false;
895 ErrCode ret = IsWifiActive(bActive);
896 reply.WriteInt32(0);
897 reply.WriteInt32(ret);
898 if (ret == WIFI_OPT_SUCCESS) {
899 reply.WriteBool(bActive);
900 }
901 return;
902 }
903
OnGetWifiState(uint32_t code,MessageParcel & data,MessageParcel & reply)904 void WifiDeviceStub::OnGetWifiState(uint32_t code, MessageParcel &data, MessageParcel &reply)
905 {
906 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
907 int state = 0;
908 ErrCode ret = GetWifiState(state);
909 reply.WriteInt32(0);
910 reply.WriteInt32(ret);
911 if (ret == WIFI_OPT_SUCCESS) {
912 reply.WriteInt32(state);
913 }
914 return;
915 }
916
OnIsMeteredHotspot(uint32_t code,MessageParcel & data,MessageParcel & reply)917 void WifiDeviceStub::OnIsMeteredHotspot(uint32_t code, MessageParcel &data, MessageParcel &reply)
918 {
919 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
920 bool bMeteredHotspot = false;
921 ErrCode ret = IsMeteredHotspot(bMeteredHotspot);
922 reply.WriteInt32(0);
923 reply.WriteInt32(ret);
924 if (ret == WIFI_OPT_SUCCESS) {
925 reply.WriteBool(bMeteredHotspot);
926 }
927 return;
928 }
929
WriteWifiLinkedInfo(MessageParcel & reply,const WifiLinkedInfo & wifiInfo)930 void WifiDeviceStub::WriteWifiLinkedInfo(MessageParcel &reply, const WifiLinkedInfo &wifiInfo)
931 {
932 reply.WriteInt32(wifiInfo.networkId);
933 reply.WriteString(wifiInfo.ssid);
934 reply.WriteString(wifiInfo.bssid);
935 reply.WriteInt32(wifiInfo.rssi);
936 reply.WriteInt32(wifiInfo.band);
937 reply.WriteInt32(wifiInfo.frequency);
938 reply.WriteInt32(wifiInfo.linkSpeed);
939 reply.WriteString(wifiInfo.macAddress);
940 reply.WriteInt32(wifiInfo.macType);
941 reply.WriteInt32(wifiInfo.ipAddress);
942 reply.WriteInt32(static_cast<int>(wifiInfo.connState));
943 reply.WriteBool(wifiInfo.ifHiddenSSID);
944 reply.WriteInt32(wifiInfo.rxLinkSpeed);
945 reply.WriteInt32(wifiInfo.txLinkSpeed);
946 reply.WriteInt32(wifiInfo.chload);
947 reply.WriteInt32(wifiInfo.snr);
948 reply.WriteInt32(wifiInfo.isDataRestricted);
949 reply.WriteString(wifiInfo.portalUrl);
950 reply.WriteInt32(static_cast<int>(wifiInfo.supplicantState));
951 reply.WriteInt32(static_cast<int>(wifiInfo.detailedState));
952 reply.WriteInt32(static_cast<int>(wifiInfo.wifiStandard));
953 reply.WriteInt32(static_cast<int>(wifiInfo.maxSupportedRxLinkSpeed));
954 reply.WriteInt32(static_cast<int>(wifiInfo.maxSupportedTxLinkSpeed));
955 reply.WriteInt32(static_cast<int>(wifiInfo.channelWidth));
956 reply.WriteBool(wifiInfo.isAncoConnected);
957 reply.WriteInt32(static_cast<int>(wifiInfo.supportedWifiCategory));
958 reply.WriteInt32(wifiInfo.isHiLinkNetwork);
959 reply.WriteBool(wifiInfo.isHiLinkProNetwork);
960 reply.WriteInt32(wifiInfo.lastRxPackets);
961 reply.WriteInt32(wifiInfo.lastTxPackets);
962 reply.WriteInt32(static_cast<int>(wifiInfo.wifiLinkType));
963 reply.WriteInt32(wifiInfo.linkId);
964 reply.WriteInt32(wifiInfo.centerFrequency0);
965 reply.WriteInt32(wifiInfo.centerFrequency1);
966 }
967
OnGetLinkedInfo(uint32_t code,MessageParcel & data,MessageParcel & reply)968 void WifiDeviceStub::OnGetLinkedInfo(uint32_t code, MessageParcel &data, MessageParcel &reply)
969 {
970 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
971 WifiLinkedInfo wifiInfo;
972 ErrCode ret = GetLinkedInfo(wifiInfo);
973 reply.WriteInt32(0);
974 reply.WriteInt32(ret);
975
976 if (ret == WIFI_OPT_SUCCESS) {
977 WriteWifiLinkedInfo(reply, wifiInfo);
978 }
979 return;
980 }
981
OnGetSignalPollInfoArray(uint32_t code,MessageParcel & data,MessageParcel & reply)982 void WifiDeviceStub::OnGetSignalPollInfoArray(uint32_t code, MessageParcel &data, MessageParcel &reply)
983 {
984 WIFI_LOGI("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
985 reply.WriteInt32(0);
986 std::vector<WifiSignalPollInfo> wifiSignalPollInfos;
987 int length = data.ReadInt32();
988 if (length > SIGNALARR_LENGTH) {
989 length = SIGNALARR_LENGTH;
990 }
991 ErrCode ret = GetSignalPollInfoArray(wifiSignalPollInfos, length);
992 reply.WriteInt32(ret);
993 if (ret == WIFI_OPT_SUCCESS) {
994 int arrayLength = static_cast<int>(wifiSignalPollInfos.size());
995 reply.WriteInt32(arrayLength);
996 for (int index = 0; index < arrayLength; index++) {
997 reply.WriteInt32(wifiSignalPollInfos[index].signal);
998 reply.WriteInt32(wifiSignalPollInfos[index].txrate);
999 reply.WriteInt32(wifiSignalPollInfos[index].rxrate);
1000 reply.WriteInt32(wifiSignalPollInfos[index].noise);
1001 reply.WriteInt32(wifiSignalPollInfos[index].txPackets);
1002 reply.WriteInt32(wifiSignalPollInfos[index].rxPackets);
1003 reply.WriteInt32(wifiSignalPollInfos[index].snr);
1004 reply.WriteInt32(wifiSignalPollInfos[index].chload);
1005 reply.WriteInt32(wifiSignalPollInfos[index].ulDelay);
1006 reply.WriteUint32(wifiSignalPollInfos[index].txBytes);
1007 reply.WriteUint32(wifiSignalPollInfos[index].rxBytes);
1008 reply.WriteInt32(wifiSignalPollInfos[index].txFailed);
1009 reply.WriteInt32(wifiSignalPollInfos[index].chloadSelf);
1010 reply.WriteInt64(wifiSignalPollInfos[index].timeStamp);
1011 }
1012 }
1013 return;
1014 }
OnGetMultiLinkedInfo(uint32_t code,MessageParcel & data,MessageParcel & reply)1015 void WifiDeviceStub::OnGetMultiLinkedInfo(uint32_t code, MessageParcel &data, MessageParcel &reply)
1016 {
1017 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1018 std::vector<WifiLinkedInfo> multiLinkedInfo;
1019 ErrCode ret = GetMultiLinkedInfo(multiLinkedInfo);
1020 reply.WriteInt32(0);
1021 if (ret != WIFI_OPT_SUCCESS) {
1022 reply.WriteInt32(ret);
1023 return;
1024 }
1025 uint32_t size = static_cast<uint32_t>(multiLinkedInfo.size());
1026 if (size > WIFI_MAX_MLO_LINK_NUM) {
1027 size = WIFI_MAX_MLO_LINK_NUM;
1028 }
1029 SendMultiLinkedInfo(size, multiLinkedInfo, reply);
1030 }
1031
SendMultiLinkedInfo(uint32_t contentSize,std::vector<WifiLinkedInfo> & result,MessageParcel & reply)1032 void WifiDeviceStub::SendMultiLinkedInfo(uint32_t contentSize, std::vector<WifiLinkedInfo> &result,
1033 MessageParcel &reply)
1034 {
1035 WIFI_LOGI("%{public}s, contentSize: %{public}d", __FUNCTION__, contentSize);
1036 std::vector<uint32_t> allSize;
1037 if (contentSize == 0) {
1038 reply.WriteInt32(WIFI_OPT_SUCCESS);
1039 reply.WriteUInt32Vector(allSize);
1040 return;
1041 }
1042 std::string name = "multiLinkedInfo";
1043 int32_t ashmemSize = WIFI_MAX_MLO_LINK_NUM;
1044 for (uint32_t i = 0; i < contentSize; i++) {
1045 MessageParcel outParcel;
1046 WriteWifiLinkedInfo(outParcel, result[i]);
1047 ashmemSize += static_cast<int>(outParcel.GetDataSize());
1048 }
1049 sptr<Ashmem> ashmem = Ashmem::CreateAshmem(name.c_str(), ashmemSize);
1050 if (ashmem == nullptr || !ashmem->MapReadAndWriteAshmem()) {
1051 reply.WriteInt32(WIFI_OPT_FAILED);
1052 if (ashmem != nullptr) {
1053 ashmem->UnmapAshmem();
1054 ashmem->CloseAshmem();
1055 }
1056 WIFI_LOGE("%{public}s ashmem create fail", __FUNCTION__);
1057 return;
1058 }
1059 int offset = 0;
1060 for (uint32_t i = 0; i < contentSize; ++i) {
1061 MessageParcel outParcel;
1062 WriteWifiLinkedInfo(outParcel, result[i]);
1063 int dataSize = static_cast<int>(outParcel.GetDataSize());
1064 if (offset + dataSize > ashmemSize) {
1065 WIFI_LOGW("%{public}s parcelLen over ssid: %{public}s, ashmemSize:%{public}d,"
1066 "dataSize:%{public}d, offset:%{public}d", __FUNCTION__, SsidAnonymize(result[i].ssid).c_str(),
1067 ashmemSize, dataSize, offset);
1068 continue;
1069 }
1070 allSize.emplace_back(dataSize);
1071 ashmem->WriteToAshmem(reinterpret_cast<void*>(outParcel.GetData()), dataSize, offset);
1072 offset += dataSize;
1073 }
1074 reply.WriteInt32(WIFI_OPT_SUCCESS);
1075 reply.WriteUInt32Vector(allSize);
1076 reply.WriteAshmem(ashmem);
1077 ashmem->UnmapAshmem();
1078 ashmem->CloseAshmem();
1079 }
1080
OnGetIpInfo(uint32_t code,MessageParcel & data,MessageParcel & reply)1081 void WifiDeviceStub::OnGetIpInfo(uint32_t code, MessageParcel &data, MessageParcel &reply)
1082 {
1083 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1084 IpInfo info;
1085 ErrCode ret = GetIpInfo(info);
1086 reply.WriteInt32(0);
1087 reply.WriteInt32(ret);
1088 if (ret == WIFI_OPT_SUCCESS) {
1089 reply.WriteInt32(info.ipAddress);
1090 reply.WriteInt32(info.gateway);
1091 reply.WriteInt32(info.netmask);
1092 reply.WriteInt32(info.primaryDns);
1093 reply.WriteInt32(info.secondDns);
1094 reply.WriteInt32(info.serverIp);
1095 reply.WriteInt32(info.leaseDuration);
1096 }
1097 return;
1098 }
1099
OnGetIpV6Info(uint32_t code,MessageParcel & data,MessageParcel & reply)1100 void WifiDeviceStub::OnGetIpV6Info(uint32_t code, MessageParcel &data, MessageParcel &reply)
1101 {
1102 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1103 IpV6Info info;
1104 ErrCode ret = GetIpv6Info(info);
1105 reply.WriteInt32(0);
1106 reply.WriteInt32(ret);
1107 if (ret == WIFI_OPT_SUCCESS) {
1108 reply.WriteString(info.linkIpV6Address);
1109 reply.WriteString(info.globalIpV6Address);
1110 reply.WriteString(info.randGlobalIpV6Address);
1111 reply.WriteString(info.uniqueLocalAddress1);
1112 reply.WriteString(info.uniqueLocalAddress2);
1113 reply.WriteString(info.gateway);
1114 reply.WriteString(info.netmask);
1115 reply.WriteString(info.primaryDns);
1116 reply.WriteString(info.secondDns);
1117 }
1118 return;
1119 }
1120
OnSetCountryCode(uint32_t code,MessageParcel & data,MessageParcel & reply)1121 void WifiDeviceStub::OnSetCountryCode(uint32_t code, MessageParcel &data, MessageParcel &reply)
1122 {
1123 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1124 ErrCode ret = WIFI_OPT_FAILED;
1125 std::string countrycode = data.ReadString();
1126 ret = SetCountryCode(countrycode);
1127 reply.WriteInt32(0);
1128 reply.WriteInt32(ret);
1129 return;
1130 }
1131
OnGetCountryCode(uint32_t code,MessageParcel & data,MessageParcel & reply)1132 void WifiDeviceStub::OnGetCountryCode(uint32_t code, MessageParcel &data, MessageParcel &reply)
1133 {
1134 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1135 std::string countryCode;
1136 ErrCode ret = GetCountryCode(countryCode);
1137 reply.WriteInt32(0);
1138 reply.WriteInt32(ret);
1139
1140 if (ret == WIFI_OPT_SUCCESS) {
1141 reply.WriteString(countryCode);
1142 }
1143
1144 return;
1145 }
1146
OnRegisterCallBack(uint32_t code,MessageParcel & data,MessageParcel & reply)1147 void WifiDeviceStub::OnRegisterCallBack(uint32_t code, MessageParcel &data, MessageParcel &reply)
1148 {
1149 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1150 ErrCode ret = WIFI_OPT_FAILED;
1151 do {
1152 sptr<IRemoteObject> remote = data.ReadRemoteObject();
1153 if (remote == nullptr) {
1154 WIFI_LOGW("Failed to ReadRemoteObject!");
1155 break;
1156 }
1157 sptr<IWifiDeviceCallBack> callback_ = iface_cast<IWifiDeviceCallBack>(remote);
1158 if (callback_ == nullptr) {
1159 callback_ = sptr<WifiDeviceCallBackProxy>::MakeSptr(remote);
1160 WIFI_LOGI("create new WifiDeviceCallBackProxy!");
1161 }
1162
1163 int pid = data.ReadInt32();
1164 int tokenId = data.ReadInt32();
1165 int eventNum = data.ReadInt32();
1166 std::vector<std::string> event;
1167 if (eventNum > 0 && eventNum <= MAX_READ_EVENT_SIZE) {
1168 for (int i = 0; i < eventNum; ++i) {
1169 event.emplace_back(data.ReadString());
1170 }
1171 }
1172 WIFI_LOGD("%{public}s, get pid: %{public}d, tokenId: %{private}d", __func__, pid, tokenId);
1173
1174 if (mSingleCallback) {
1175 ret = RegisterCallBack(callback_, event);
1176 } else {
1177 std::unique_lock<std::mutex> lock(deathRecipientMutex);
1178 if (deathRecipient_ == nullptr) {
1179 deathRecipient_ = sptr<WifiDeviceDeathRecipient>::MakeSptr();
1180 }
1181 // Add death recipient to remote object if this is the first time to register callback.
1182 if (remote->IsProxyObject() &&
1183 !WifiInternalEventDispatcher::GetInstance().HasStaRemote(remote, m_instId)) {
1184 remote->AddDeathRecipient(deathRecipient_);
1185 }
1186 if (callback_ != nullptr) {
1187 for (const auto &eventName : event) {
1188 ret = WifiInternalEventDispatcher::GetInstance().AddStaCallback(remote, callback_, pid, eventName,
1189 tokenId, m_instId);
1190 }
1191 }
1192 }
1193 } while (0);
1194 reply.WriteInt32(0);
1195 reply.WriteInt32(ret);
1196 return;
1197 }
1198
OnGetSignalLevel(uint32_t code,MessageParcel & data,MessageParcel & reply)1199 void WifiDeviceStub::OnGetSignalLevel(uint32_t code, MessageParcel &data, MessageParcel &reply)
1200 {
1201 int rssi = data.ReadInt32();
1202 int band = data.ReadInt32();
1203 int level = 0;
1204 ErrCode ret = GetSignalLevel(rssi, band, level);
1205 reply.WriteInt32(0);
1206 reply.WriteInt32(ret);
1207 if (ret == WIFI_OPT_SUCCESS) {
1208 reply.WriteInt32(level);
1209 }
1210 return;
1211 }
1212
OnGetSupportedFeatures(uint32_t code,MessageParcel & data,MessageParcel & reply)1213 void WifiDeviceStub::OnGetSupportedFeatures(uint32_t code, MessageParcel &data, MessageParcel &reply)
1214 {
1215 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1216 long features = 0;
1217 int ret = GetSupportedFeatures(features);
1218 reply.WriteInt32(0);
1219 reply.WriteInt32(ret);
1220
1221 if (ret == WIFI_OPT_SUCCESS) {
1222 reply.WriteInt64(features);
1223 }
1224
1225 return;
1226 }
1227
OnIsFeatureSupported(uint32_t code,MessageParcel & data,MessageParcel & reply)1228 void WifiDeviceStub::OnIsFeatureSupported(uint32_t code, MessageParcel &data, MessageParcel &reply)
1229 {
1230 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1231 bool isSupported = false;
1232 long feature = data.ReadInt64();
1233 int ret = IsFeatureSupported(feature, isSupported);
1234 reply.WriteInt32(0);
1235 reply.WriteInt32(ret);
1236
1237 if (ret == WIFI_OPT_SUCCESS) {
1238 reply.WriteInt32(isSupported);
1239 }
1240
1241 return;
1242 }
1243
OnGetDeviceMacAdd(uint32_t code,MessageParcel & data,MessageParcel & reply)1244 void WifiDeviceStub::OnGetDeviceMacAdd(uint32_t code, MessageParcel &data, MessageParcel &reply)
1245 {
1246 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1247 std::string strMacAddr;
1248 ErrCode ret = GetDeviceMacAddress(strMacAddr);
1249 reply.WriteInt32(0);
1250 reply.WriteInt32(ret);
1251 if (ret == WIFI_OPT_SUCCESS) {
1252 reply.WriteCString(strMacAddr.c_str());
1253 }
1254
1255 return;
1256 }
1257
OnSetLowLatencyMode(uint32_t code,MessageParcel & data,MessageParcel & reply)1258 void WifiDeviceStub::OnSetLowLatencyMode(uint32_t code, MessageParcel &data, MessageParcel &reply)
1259 {
1260 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1261
1262 bool enabled = data.ReadBool();
1263 reply.WriteInt32(0);
1264 reply.WriteBool(SetLowLatencyMode(enabled));
1265 }
1266
OnRemoveCandidateConfig(uint32_t code,MessageParcel & data,MessageParcel & reply)1267 void WifiDeviceStub::OnRemoveCandidateConfig(uint32_t code, MessageParcel &data, MessageParcel &reply)
1268 {
1269 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1270 ErrCode ret = WIFI_OPT_FAILED;
1271 int flag = data.ReadInt32();
1272 /* Read a flag: 1-remove config by networkId, 2-remove config by WifiDeviceConfig */
1273 if (flag == 1) {
1274 int networkId = data.ReadInt32();
1275 WIFI_LOGI("Remove candidate config by networkId: %{public}d", networkId);
1276 ret = RemoveCandidateConfig(networkId);
1277 } else {
1278 WifiDeviceConfig config;
1279 ReadWifiDeviceConfig(data, config);
1280 WIFI_LOGD("Remove candidate config by config: %{public}s", SsidAnonymize(config.ssid).c_str());
1281 ret = RemoveCandidateConfig(config);
1282 }
1283 reply.WriteInt32(0);
1284 reply.WriteInt32(ret);
1285 return;
1286 }
1287
OnIsBandTypeSupported(uint32_t code,MessageParcel & data,MessageParcel & reply)1288 void WifiDeviceStub::OnIsBandTypeSupported(uint32_t code, MessageParcel &data, MessageParcel &reply)
1289 {
1290 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1291 ErrCode ret = WIFI_OPT_FAILED;
1292 int bandType = data.ReadInt32();
1293 bool result = false;
1294 ret = IsBandTypeSupported(bandType, result);
1295 reply.WriteInt32(0);
1296 reply.WriteInt32(ret);
1297 reply.WriteBool(result);
1298 return;
1299 }
1300
OnGet5GHzChannelList(uint32_t code,MessageParcel & data,MessageParcel & reply)1301 void WifiDeviceStub::OnGet5GHzChannelList(uint32_t code, MessageParcel &data, MessageParcel &reply)
1302 {
1303 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1304 std::vector<int> channelList;
1305 ErrCode ret = Get5GHzChannelList(channelList);
1306 reply.WriteInt32(0);
1307 reply.WriteInt32(ret);
1308 if (ret == WIFI_OPT_SUCCESS) {
1309 unsigned int size = channelList.size();
1310 reply.WriteInt32(size);
1311 for (unsigned int i = 0; i < size; ++i) {
1312 reply.WriteInt32(channelList[i]);
1313 }
1314 }
1315 return;
1316 }
1317
OnStartPortalCertification(uint32_t code,MessageParcel & data,MessageParcel & reply)1318 void WifiDeviceStub::OnStartPortalCertification(uint32_t code, MessageParcel &data, MessageParcel &reply)
1319 {
1320 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1321 ErrCode ret = StartPortalCertification();
1322 reply.WriteInt32(0);
1323 reply.WriteInt32(ret);
1324 return;
1325 }
1326
OnGetDisconnectedReason(uint32_t code,MessageParcel & data,MessageParcel & reply)1327 void WifiDeviceStub::OnGetDisconnectedReason(uint32_t code, MessageParcel &data, MessageParcel &reply)
1328 {
1329 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1330 DisconnectedReason reason = DisconnectedReason::DISC_REASON_DEFAULT;
1331 ErrCode ret = GetDisconnectedReason(reason);
1332 reply.WriteInt32(0);
1333 reply.WriteInt32(ret);
1334 if (ret == WIFI_OPT_SUCCESS) {
1335 reply.WriteInt32((int)reason);
1336 }
1337 return;
1338 }
1339
OnSetFrozenApp(uint32_t code,MessageParcel & data,MessageParcel & reply)1340 void WifiDeviceStub::OnSetFrozenApp(uint32_t code, MessageParcel& data, MessageParcel& reply)
1341 {
1342 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1343 int size = data.ReadInt32();
1344 size = size < MAX_PID_LIST_SIZE ? size : MAX_PID_LIST_SIZE;
1345 std::set<int> pidList;
1346 for (int i = 0; i < size; i++) {
1347 pidList.insert(data.ReadInt32());
1348 }
1349 bool frozen = data.ReadBool();
1350 ErrCode ret = SetAppFrozen(pidList, frozen);
1351 reply.WriteInt32(0);
1352 reply.WriteInt32(ret);
1353 return;
1354 }
1355
OnResetAllFrozenApp(uint32_t code,MessageParcel & data,MessageParcel & reply)1356 void WifiDeviceStub::OnResetAllFrozenApp(uint32_t code, MessageParcel& data, MessageParcel& reply)
1357 {
1358 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1359 ErrCode ret = ResetAllFrozenApp();
1360 reply.WriteInt32(0);
1361 reply.WriteInt32(ret);
1362 return;
1363 }
1364
OnDisableAutoJoin(uint32_t code,MessageParcel & data,MessageParcel & reply)1365 void WifiDeviceStub::OnDisableAutoJoin(uint32_t code, MessageParcel& data, MessageParcel& reply)
1366 {
1367 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1368 ErrCode ret = DisableAutoJoin(data.ReadString());
1369 reply.WriteInt32(0);
1370 reply.WriteInt32(ret);
1371 return;
1372 }
1373
OnEnableAutoJoin(uint32_t code,MessageParcel & data,MessageParcel & reply)1374 void WifiDeviceStub::OnEnableAutoJoin(uint32_t code, MessageParcel& data, MessageParcel& reply)
1375 {
1376 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1377 ErrCode ret = EnableAutoJoin(data.ReadString());
1378 reply.WriteInt32(0);
1379 reply.WriteInt32(ret);
1380 return;
1381 }
1382
OnFactoryReset(uint32_t code,MessageParcel & data,MessageParcel & reply)1383 void WifiDeviceStub::OnFactoryReset(uint32_t code, MessageParcel &data, MessageParcel &reply)
1384 {
1385 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1386 ErrCode ret = FactoryReset();
1387 reply.WriteInt32(0);
1388 reply.WriteInt32(ret);
1389 return;
1390 }
1391
OnReceiveNetworkControlInfo(uint32_t code,MessageParcel & data,MessageParcel & reply)1392 void WifiDeviceStub::OnReceiveNetworkControlInfo(uint32_t code, MessageParcel &data, MessageParcel &reply)
1393 {
1394 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1395 WifiNetworkControlInfo networkControlInfo;
1396 networkControlInfo.uid = data.ReadInt32();
1397 networkControlInfo.pid = data.ReadInt32();
1398 networkControlInfo.bundleName = data.ReadString();
1399 networkControlInfo.state = data.ReadInt32();
1400 networkControlInfo.sceneId = data.ReadInt32();
1401 networkControlInfo.rtt = data.ReadInt32();
1402 ErrCode ret = ReceiveNetworkControlInfo(networkControlInfo);
1403 reply.WriteInt32(0);
1404 reply.WriteInt32(ret);
1405 return;
1406 }
1407
OnLimitSpeed(uint32_t code,MessageParcel & data,MessageParcel & reply)1408 void WifiDeviceStub::OnLimitSpeed(uint32_t code, MessageParcel &data, MessageParcel &reply)
1409 {
1410 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1411 int controlId = data.ReadInt32();
1412 int limitMode = data.ReadInt32();
1413 ErrCode ret = LimitSpeed(controlId, limitMode);
1414 reply.WriteInt32(0);
1415 reply.WriteInt32(ret);
1416 return;
1417 }
1418
OnEnableHiLinkHandshake(uint32_t code,MessageParcel & data,MessageParcel & reply)1419 void WifiDeviceStub::OnEnableHiLinkHandshake(uint32_t code, MessageParcel &data, MessageParcel &reply)
1420 {
1421 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1422 bool uiFlag = data.ReadBool();
1423 std::string bssid = data.ReadString();
1424 WifiDeviceConfig deviceConfig;
1425 ReadWifiDeviceConfig(data, deviceConfig);
1426 ErrCode ret = EnableHiLinkHandshake(uiFlag, bssid, deviceConfig);
1427 reply.WriteInt32(0);
1428 reply.WriteInt32(ret);
1429 return;
1430 }
1431
OnSetSatelliteState(uint32_t code,MessageParcel & data,MessageParcel & reply)1432 void WifiDeviceStub::OnSetSatelliteState(uint32_t code, MessageParcel &data, MessageParcel &reply)
1433 {
1434 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1435 int state = data.ReadInt32();
1436 ErrCode ret = SetSatelliteState(state);
1437 reply.WriteInt32(0);
1438 reply.WriteInt32(ret);
1439 return;
1440 }
1441
OnEnableSemiWifi(uint32_t code,MessageParcel & data,MessageParcel & reply)1442 void WifiDeviceStub::OnEnableSemiWifi(uint32_t code, MessageParcel &data, MessageParcel &reply)
1443 {
1444 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1445 ErrCode ret = EnableSemiWifi();
1446 reply.WriteInt32(0);
1447 reply.WriteInt32(ret);
1448 return;
1449 }
1450
OnGetWifiDetailState(uint32_t code,MessageParcel & data,MessageParcel & reply)1451 void WifiDeviceStub::OnGetWifiDetailState(uint32_t code, MessageParcel &data, MessageParcel &reply)
1452 {
1453 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1454 WifiDetailState state = WifiDetailState::STATE_UNKNOWN;
1455 ErrCode ret = GetWifiDetailState(state);
1456 reply.WriteInt32(0);
1457 reply.WriteInt32(ret);
1458 if (ret == WIFI_OPT_SUCCESS) {
1459 reply.WriteInt32(static_cast<int>(state));
1460 }
1461
1462 return;
1463 }
1464
OnSetLowTxPower(uint32_t code,MessageParcel & data,MessageParcel & reply)1465 void WifiDeviceStub::OnSetLowTxPower(uint32_t code, MessageParcel &data, MessageParcel &reply)
1466 {
1467 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1468 WifiLowPowerParam wifiLowPowerParam;
1469 wifiLowPowerParam.ifName = data.ReadString();
1470 wifiLowPowerParam.scene = data.ReadInt32();
1471 wifiLowPowerParam.rssiThreshold = data.ReadInt32();
1472 wifiLowPowerParam.peerMacaddr = data.ReadString();
1473 wifiLowPowerParam.powerParam = data.ReadString();
1474 wifiLowPowerParam.powerParamLen = data.ReadInt32();
1475 ErrCode ret = SetLowTxPower(wifiLowPowerParam);
1476 reply.WriteInt32(0);
1477 reply.WriteInt32(ret);
1478 return;
1479 }
1480
OnSetTxPower(uint32_t code,MessageParcel & data,MessageParcel & reply)1481 void WifiDeviceStub::OnSetTxPower(uint32_t code, MessageParcel &data, MessageParcel &reply)
1482 {
1483 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1484 int power = data.ReadInt32();
1485 ErrCode ret = SetTxPower(power);
1486 reply.WriteInt32(0);
1487 reply.WriteInt32(ret);
1488 return;
1489 }
1490
OnGetDeviceConfig(uint32_t code,MessageParcel & data,MessageParcel & reply)1491 void WifiDeviceStub::OnGetDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply)
1492 {
1493 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1494 int networkId = data.ReadInt32();
1495 WifiDeviceConfig config;
1496 ErrCode ret = GetDeviceConfig(networkId, config);
1497 reply.WriteInt32(0);
1498 reply.WriteInt32(ret);
1499 if (ret != WIFI_OPT_SUCCESS) {
1500 return;
1501 }
1502 WriteWifiDeviceConfig(reply, config);
1503 return;
1504 }
1505
OnSetDpiMarkRule(uint32_t code,MessageParcel & data,MessageParcel & reply)1506 void WifiDeviceStub::OnSetDpiMarkRule(uint32_t code, MessageParcel &data, MessageParcel &reply)
1507 {
1508 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1509 ErrCode ret = WIFI_OPT_FAILED;
1510 const char *readStr = data.ReadCString();
1511 int uid = data.ReadInt32();
1512 int protocol = data.ReadInt32();
1513 int enable = data.ReadInt32();
1514 if (readStr == nullptr) {
1515 ret = WIFI_OPT_INVALID_PARAM;
1516 } else {
1517 std::string ifaceName = readStr;
1518 ret = SetDpiMarkRule(ifaceName, uid, protocol, enable);
1519 }
1520 reply.WriteInt32(0);
1521 reply.WriteInt32(ret);
1522 return;
1523 }
1524
OnUpdateNetworkLagInfo(uint32_t code,MessageParcel & data,MessageParcel & reply)1525 void WifiDeviceStub::OnUpdateNetworkLagInfo(uint32_t code, MessageParcel &data, MessageParcel &reply)
1526 {
1527 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1528 NetworkLagType networkLagType = static_cast<NetworkLagType>(data.ReadInt32());
1529 NetworkLagInfo networkLagInfo;
1530 networkLagInfo.uid = static_cast<uint32_t>(data.ReadInt32());
1531 ErrCode ret = UpdateNetworkLagInfo(networkLagType, networkLagInfo);
1532 reply.WriteInt32(0);
1533 reply.WriteInt32(ret);
1534 return;
1535 }
1536
OnFetchWifiSignalInfoForVoWiFi(uint32_t code,MessageParcel & data,MessageParcel & reply)1537 void WifiDeviceStub::OnFetchWifiSignalInfoForVoWiFi(uint32_t code, MessageParcel &data, MessageParcel &reply)
1538 {
1539 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1540 VoWifiSignalInfo signalInfo;
1541 ErrCode ret = FetchWifiSignalInfoForVoWiFi(signalInfo);
1542 reply.WriteInt32(0);
1543 reply.WriteInt32(ret);
1544 if (ret == WIFI_OPT_SUCCESS) {
1545 reply.WriteInt32(signalInfo.rssi);
1546 reply.WriteInt32(signalInfo.noise);
1547 reply.WriteInt32(signalInfo.bler);
1548 reply.WriteInt32(signalInfo.deltaTxPacketCounter);
1549 reply.WriteInt32(signalInfo.accessType);
1550 reply.WriteInt32(signalInfo.reverse);
1551 reply.WriteInt64(signalInfo.txGood);
1552 reply.WriteInt64(signalInfo.txBad);
1553 reply.WriteString(signalInfo.macAddress);
1554 }
1555 return;
1556 }
1557
OnIsSupportVoWifiDetect(uint32_t code,MessageParcel & data,MessageParcel & reply)1558 void WifiDeviceStub::OnIsSupportVoWifiDetect(uint32_t code, MessageParcel &data, MessageParcel &reply)
1559 {
1560 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1561 bool isSupported;
1562 ErrCode ret = IsSupportVoWifiDetect(isSupported);
1563 reply.WriteInt32(0);
1564 reply.WriteInt32(ret);
1565 if (ret == WIFI_OPT_SUCCESS) {
1566 reply.WriteBool(isSupported);
1567 }
1568 return;
1569 }
1570
OnSetVoWifiDetectMode(uint32_t code,MessageParcel & data,MessageParcel & reply)1571 void WifiDeviceStub::OnSetVoWifiDetectMode(uint32_t code, MessageParcel &data, MessageParcel &reply)
1572 {
1573 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1574 WifiDetectConfInfo info;
1575 info.wifiDetectMode = data.ReadInt32();
1576 info.threshold = data.ReadInt32();
1577 info.envalueCount = data.ReadInt32();
1578 ErrCode ret = SetVoWifiDetectMode(info);
1579 reply.WriteInt32(0);
1580 reply.WriteInt32(ret);
1581 return;
1582 }
1583
OnGetVoWifiDetectMode(uint32_t code,MessageParcel & data,MessageParcel & reply)1584 void WifiDeviceStub::OnGetVoWifiDetectMode(uint32_t code, MessageParcel &data, MessageParcel &reply)
1585 {
1586 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1587 WifiDetectConfInfo info;
1588 ErrCode ret = GetVoWifiDetectMode(info);
1589 reply.WriteInt32(0);
1590 reply.WriteInt32(ret);
1591 if (ret == WIFI_OPT_SUCCESS) {
1592 reply.WriteInt32(info.wifiDetectMode);
1593 reply.WriteInt32(info.threshold);
1594 reply.WriteInt32(info.envalueCount);
1595 }
1596 return;
1597 }
1598
OnSetVoWifiDetectPeriod(uint32_t code,MessageParcel & data,MessageParcel & reply)1599 void WifiDeviceStub::OnSetVoWifiDetectPeriod(uint32_t code, MessageParcel &data, MessageParcel &reply)
1600 {
1601 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1602 int period = data.ReadInt32();
1603 ErrCode ret = SetVoWifiDetectPeriod(period);
1604 reply.WriteInt32(0);
1605 reply.WriteInt32(ret);
1606 return;
1607 }
1608
OnGetVoWifiDetectPeriod(uint32_t code,MessageParcel & data,MessageParcel & reply)1609 void WifiDeviceStub::OnGetVoWifiDetectPeriod(uint32_t code, MessageParcel &data, MessageParcel &reply)
1610 {
1611 WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
1612 int period;
1613 ErrCode ret = GetVoWifiDetectPeriod(period);
1614 reply.WriteInt32(0);
1615 reply.WriteInt32(ret);
1616 if (ret == WIFI_OPT_SUCCESS) {
1617 reply.WriteInt32(period);
1618 }
1619 return;
1620 }
1621 } // namespace Wifi
1622 } // namespace OHOS
1623