1 /*
2 * Copyright (C) 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_hotspot_mgr_proxy.h"
17 #include "ipc_types.h"
18 #include "message_option.h"
19 #include "message_parcel.h"
20 #include "wifi_logger.h"
21 #include "wifi_manager_service_ipc_interface_code.h"
22
23 DEFINE_WIFILOG_HOTSPOT_LABEL("WifiHotspotMgrProxy");
24 namespace OHOS {
25 namespace Wifi {
GetWifiRemote(int id)26 sptr<IRemoteObject> WifiHotspotMgrProxy::GetWifiRemote(int id)
27 {
28 MessageOption option;
29 MessageParcel data;
30 MessageParcel reply;
31 if (!data.WriteInterfaceToken(GetDescriptor())) {
32 WIFI_LOGE("Write interface token error: %{public}s", __func__);
33 return nullptr;
34 }
35 data.WriteInt32(id);
36 int error = Remote()->SendRequest(static_cast<uint32_t>(HotspotInterfaceCode::WIFI_MGR_GET_HOTSPOT_SERVICE), data,
37 reply, option);
38 if (error != ERR_NONE) {
39 WIFI_LOGE("Get remote object id %{public}d failed,error code is %{public}d", id, error);
40 return nullptr;
41 }
42
43 return reply.ReadRemoteObject();
44 }
45 } // namespace Wifi
46 } // namespace OHOS
47