• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 "usb_srv_client.h"
17 #include "datetime_ex.h"
18 #include "if_system_ability_manager.h"
19 #include "ipc_skeleton.h"
20 #include "iservice_registry.h"
21 #include "string_ex.h"
22 #include "system_ability_definition.h"
23 #include "usb_common.h"
24 #include "usb_device.h"
25 #include "usb_errors.h"
26 
27 using namespace OHOS::HDI::Usb::V1_0;
28 namespace OHOS {
29 namespace USB {
UsbSrvClient()30 UsbSrvClient::UsbSrvClient()
31 {
32     Connect();
33 }
~UsbSrvClient()34 UsbSrvClient::~UsbSrvClient() {}
35 
Connect()36 int32_t UsbSrvClient::Connect()
37 {
38     std::lock_guard<std::mutex> lock(mutex_);
39     if (proxy_ != nullptr) {
40         return UEC_OK;
41     }
42     sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
43     if (sm == nullptr) {
44         USB_HILOGE(MODULE_USB_INNERKIT, "fail to get SystemAbilityManager");
45         return UEC_INTERFACE_GET_SYSTEM_ABILITY_MANAGER_FAILED;
46     }
47     sptr<IRemoteObject> remoteObject = sm->CheckSystemAbility(USB_SYSTEM_ABILITY_ID);
48     if (remoteObject == nullptr) {
49         USB_HILOGE(MODULE_USB_INNERKIT, "GetSystemAbility failed.");
50         return UEC_INTERFACE_GET_USB_SERVICE_FAILED;
51     }
52     proxy_ = iface_cast<IUsbSrv>(remoteObject);
53     USB_HILOGI(MODULE_USB_INNERKIT, "Connect UsbService ok.");
54     sptr<IRemoteObject> deathObject = proxy_->AsObject();
55     if (deathObject == nullptr) {
56         USB_HILOGI(MODULE_USB_INNERKIT, "deathObject is null.");
57         return UEC_INTERFACE_DEAD_OBJECT;
58     }
59     deathRecipient_  = new UsbSrvDeathRecipient();
60     deathObject->AddDeathRecipient(deathRecipient_);
61     return UEC_OK;
62 }
63 
ResetProxy(const wptr<IRemoteObject> & remote)64 void UsbSrvClient::ResetProxy(const wptr<IRemoteObject> &remote)
65 {
66     std::lock_guard<std::mutex> lock(mutex_);
67     RETURN_IF(proxy_ == nullptr);
68     auto serviceRemote = proxy_->AsObject();
69     if ((serviceRemote != nullptr) && (serviceRemote == remote.promote())) {
70         serviceRemote->RemoveDeathRecipient(deathRecipient_);
71         proxy_ = nullptr;
72     }
73 }
74 
OnRemoteDied(const wptr<IRemoteObject> & remote)75 void UsbSrvClient::UsbSrvDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
76 {
77     if (remote == nullptr) {
78         USB_HILOGE(MODULE_USB_INNERKIT, "UsbSrvDeathRecipient::OnRemoteDied failed, remote is nullptr.");
79         return;
80     }
81     UsbSrvClient::GetInstance().ResetProxy(remote);
82     USB_HILOGI(MODULE_USB_INNERKIT, "UsbSrvDeathRecipient::Recv death notice.");
83 }
84 
OpenDevice(const UsbDevice & device,USBDevicePipe & pipe)85 int32_t UsbSrvClient::OpenDevice(const UsbDevice &device, USBDevicePipe &pipe)
86 {
87     USB_HILOGI(MODULE_USB_INNERKIT, "Calling OpenDevice Start!");
88     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
89     int32_t ret = proxy_->OpenDevice(device.GetBusNum(), device.GetDevAddr());
90     if (ret != UEC_OK) {
91         USB_HILOGE(MODULE_USB_INNERKIT, "OpenDevice failed with ret = %{public}d !", ret);
92         return ret;
93     }
94 
95     pipe.SetBusNum(device.GetBusNum());
96     pipe.SetDevAddr(device.GetDevAddr());
97     return UEC_OK;
98 }
99 
HasRight(std::string deviceName)100 bool UsbSrvClient::HasRight(std::string deviceName)
101 {
102     USB_HILOGI(MODULE_USB_INNERKIT, "Calling HasRight Start!");
103     RETURN_IF_WITH_RET(Connect() != UEC_OK, false);
104     return proxy_->HasRight(deviceName);
105 }
106 
RequestRight(std::string deviceName)107 int32_t UsbSrvClient::RequestRight(std::string deviceName)
108 {
109     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
110     int32_t ret = proxy_->RequestRight(deviceName);
111     if (ret != UEC_OK) {
112         USB_HILOGE(MODULE_USB_INNERKIT, "Calling RequestRight failed with ret = %{public}d !", ret);
113     }
114     return ret;
115 }
116 
RemoveRight(std::string deviceName)117 int32_t UsbSrvClient::RemoveRight(std::string deviceName)
118 {
119     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
120     int32_t ret = proxy_->RemoveRight(deviceName);
121     if (ret != UEC_OK) {
122         USB_HILOGE(MODULE_USB_INNERKIT, "Calling RequestRight failed with ret = %{public}d !", ret);
123     }
124     return ret;
125 }
126 
GetDevices(std::vector<UsbDevice> & deviceList)127 int32_t UsbSrvClient::GetDevices(std::vector<UsbDevice> &deviceList)
128 {
129     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
130     int32_t ret = proxy_->GetDevices(deviceList);
131     if (ret != UEC_OK) {
132         USB_HILOGE(MODULE_USB_INNERKIT, "GetDevices failed ret = %{public}d!", ret);
133     }
134     USB_HILOGI(MODULE_USB_INNERKIT, "list size = %{public}zu!", deviceList.size());
135     return ret;
136 }
137 
GetCurrentFunctions(int32_t & funcs)138 int32_t UsbSrvClient::GetCurrentFunctions(int32_t &funcs)
139 {
140     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
141     int32_t ret = proxy_->GetCurrentFunctions(funcs);
142     if (ret != UEC_OK) {
143         USB_HILOGE(MODULE_USB_INNERKIT, "failed ret = %{public}d!", ret);
144     }
145     USB_HILOGI(MODULE_USB_INNERKIT, " Calling GetCurrentFunctions Success!");
146     return ret;
147 }
148 
SetCurrentFunctions(int32_t funcs)149 int32_t UsbSrvClient::SetCurrentFunctions(int32_t funcs)
150 {
151     RETURN_IF_WITH_RET(Connect() != UEC_OK, false);
152     int32_t ret = proxy_->SetCurrentFunctions(funcs);
153     if (ret != UEC_OK) {
154         USB_HILOGE(MODULE_USB_INNERKIT, "failed ret = %{public}d!", ret);
155         return ret;
156     }
157     USB_HILOGI(MODULE_USB_INNERKIT, " Calling SetCurrentFunctions Success!");
158     return ret;
159 }
160 
UsbFunctionsFromString(std::string_view funcs)161 int32_t UsbSrvClient::UsbFunctionsFromString(std::string_view funcs)
162 {
163     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
164     int32_t result = proxy_->UsbFunctionsFromString(funcs);
165     USB_HILOGI(MODULE_USB_INNERKIT, " Calling UsbFunctionsFromString Success!");
166     return result;
167 }
168 
UsbFunctionsToString(int32_t funcs)169 std::string UsbSrvClient::UsbFunctionsToString(int32_t funcs)
170 {
171     std::string result;
172     RETURN_IF_WITH_RET(Connect() != UEC_OK, result);
173     result = proxy_->UsbFunctionsToString(funcs);
174     USB_HILOGI(MODULE_USB_INNERKIT, " Calling UsbFunctionsToString Success!");
175     return result;
176 }
177 
GetPorts(std::vector<UsbPort> & usbports)178 int32_t UsbSrvClient::GetPorts(std::vector<UsbPort> &usbports)
179 {
180     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
181     USB_HILOGI(MODULE_USB_INNERKIT, " Calling GetPorts");
182     int32_t ret = proxy_->GetPorts(usbports);
183     if (ret != UEC_OK) {
184         USB_HILOGE(MODULE_USB_INNERKIT, "failed ret = %{public}d!", ret);
185     }
186     return ret;
187 }
188 
GetSupportedModes(int32_t portId,int32_t & result)189 int32_t UsbSrvClient::GetSupportedModes(int32_t portId, int32_t &result)
190 {
191     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
192     USB_HILOGI(MODULE_USB_INNERKIT, " Calling GetSupportedModes");
193     int32_t ret = proxy_->GetSupportedModes(portId, result);
194     if (ret != UEC_OK) {
195         USB_HILOGE(MODULE_USB_INNERKIT, "failed ret = %{public}d!", ret);
196     }
197     return ret;
198 }
199 
SetPortRole(int32_t portId,int32_t powerRole,int32_t dataRole)200 int32_t UsbSrvClient::SetPortRole(int32_t portId, int32_t powerRole, int32_t dataRole)
201 {
202     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
203     USB_HILOGI(MODULE_USB_INNERKIT, "Calling SetPortRole");
204     int32_t ret = proxy_->SetPortRole(portId, powerRole, dataRole);
205     if (ret != UEC_OK) {
206         USB_HILOGE(MODULE_USB_INNERKIT, "failed ret = %{public}d!", ret);
207     }
208     return ret;
209 }
210 
ClaimInterface(USBDevicePipe & pipe,const UsbInterface & interface,bool force)211 int32_t UsbSrvClient::ClaimInterface(USBDevicePipe &pipe, const UsbInterface &interface, bool force)
212 {
213     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
214     int32_t ret = proxy_->ClaimInterface(pipe.GetBusNum(), pipe.GetDevAddr(), interface.GetId(), force);
215     if (ret != UEC_OK) {
216         USB_HILOGE(MODULE_USB_INNERKIT, "failed width ret = %{public}d !", ret);
217     }
218     return ret;
219 }
220 
ReleaseInterface(USBDevicePipe & pipe,const UsbInterface & interface)221 int32_t UsbSrvClient::ReleaseInterface(USBDevicePipe &pipe, const UsbInterface &interface)
222 {
223     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
224     int32_t ret = proxy_->ReleaseInterface(pipe.GetBusNum(), pipe.GetDevAddr(), interface.GetId());
225     if (ret != UEC_OK) {
226         USB_HILOGE(MODULE_USB_INNERKIT, "failed width ret = %{public}d !", ret);
227     }
228     return ret;
229 }
230 
BulkTransfer(USBDevicePipe & pipe,const USBEndpoint & endpoint,std::vector<uint8_t> & bufferData,int32_t timeOut)231 int32_t UsbSrvClient::BulkTransfer(
232     USBDevicePipe &pipe, const USBEndpoint &endpoint, std::vector<uint8_t> &bufferData, int32_t timeOut)
233 {
234     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
235     int32_t ret = UEC_INTERFACE_INVALID_VALUE;
236     const UsbDev tdev = {pipe.GetBusNum(), pipe.GetDevAddr()};
237     const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
238     if (USB_ENDPOINT_DIR_IN == endpoint.GetDirection()) {
239         ret = proxy_->BulkTransferRead(tdev, tpipe, bufferData, timeOut);
240     } else if (USB_ENDPOINT_DIR_OUT == endpoint.GetDirection()) {
241         ret = proxy_->BulkTransferWrite(tdev, tpipe, bufferData, timeOut);
242     }
243     if (ret != UEC_OK) {
244         USB_HILOGE(MODULE_USB_INNERKIT, "failed width ret = %{public}d !", ret);
245     }
246     return ret;
247 }
248 
ControlTransfer(USBDevicePipe & pipe,const UsbCtrlTransfer & ctrl,std::vector<uint8_t> & bufferData)249 int32_t UsbSrvClient::ControlTransfer(
250     USBDevicePipe &pipe, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &bufferData)
251 {
252     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
253     const UsbDev dev = {pipe.GetBusNum(), pipe.GetDevAddr()};
254     int32_t ret = proxy_->ControlTransfer(dev, ctrl, bufferData);
255     if (ret != UEC_OK) {
256         USB_HILOGE(MODULE_USB_INNERKIT, "failed width ret = %{public}d !", ret);
257     }
258 
259     return ret;
260 }
261 
SetConfiguration(USBDevicePipe & pipe,const USBConfig & config)262 int32_t UsbSrvClient::SetConfiguration(USBDevicePipe &pipe, const USBConfig &config)
263 {
264     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
265     int32_t ret = proxy_->SetActiveConfig(pipe.GetBusNum(), pipe.GetDevAddr(), config.GetId());
266     return ret;
267 }
268 
SetInterface(USBDevicePipe & pipe,const UsbInterface & interface)269 int32_t UsbSrvClient::SetInterface(USBDevicePipe &pipe, const UsbInterface &interface)
270 {
271     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
272     return proxy_->SetInterface(
273         pipe.GetBusNum(), pipe.GetDevAddr(), interface.GetId(), interface.GetAlternateSetting());
274 }
275 
GetRawDescriptors(USBDevicePipe & pipe,std::vector<uint8_t> & bufferData)276 int32_t UsbSrvClient::GetRawDescriptors(USBDevicePipe &pipe, std::vector<uint8_t> &bufferData)
277 {
278     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
279     int32_t ret = proxy_->GetRawDescriptor(pipe.GetBusNum(), pipe.GetDevAddr(), bufferData);
280     if (ret != UEC_OK) {
281         USB_HILOGE(MODULE_USB_INNERKIT, "failed ret = %{public}d!", ret);
282     }
283     return ret;
284 }
285 
GetFileDescriptor(USBDevicePipe & pipe,int32_t & fd)286 int32_t UsbSrvClient::GetFileDescriptor(USBDevicePipe &pipe, int32_t &fd)
287 {
288     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
289     int32_t ret = proxy_->GetFileDescriptor(pipe.GetBusNum(), pipe.GetDevAddr(), fd);
290     if (ret != UEC_OK) {
291         USB_HILOGE(MODULE_USB_INNERKIT, "failed ret = %{public}d!", ret);
292     }
293     return ret;
294 }
295 
Close(const USBDevicePipe & pipe)296 bool UsbSrvClient::Close(const USBDevicePipe &pipe)
297 {
298     RETURN_IF_WITH_RET(proxy_ == nullptr, false);
299     int32_t ret = proxy_->Close(pipe.GetBusNum(), pipe.GetDevAddr());
300     return (ret == UEC_OK);
301 }
302 
PipeRequestWait(USBDevicePipe & pipe,int64_t timeOut,UsbRequest & req)303 int32_t UsbSrvClient::PipeRequestWait(USBDevicePipe &pipe, int64_t timeOut, UsbRequest &req)
304 {
305     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
306     std::vector<uint8_t> clientData;
307     std::vector<uint8_t> bufferData;
308     const UsbDev tdev = {pipe.GetBusNum(), pipe.GetDevAddr()};
309     int32_t ret = proxy_->RequestWait(tdev, timeOut, clientData, bufferData);
310     if (ret != UEC_OK) {
311         USB_HILOGE(MODULE_USB_INNERKIT, "failed width ret = %{public}d.", ret);
312         return ret;
313     }
314 
315     req.SetPipe(pipe);
316     req.SetClientData(clientData);
317     req.SetReqData(bufferData);
318     return ret;
319 }
320 
RequestInitialize(UsbRequest & request)321 int32_t UsbSrvClient::RequestInitialize(UsbRequest &request)
322 {
323     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
324     const USBDevicePipe &pipe = request.GetPipe();
325     const USBEndpoint &endpoint = request.GetEndpoint();
326     return proxy_->ClaimInterface(pipe.GetBusNum(), pipe.GetDevAddr(), endpoint.GetInterfaceId(), CLAIM_FORCE_1);
327 }
328 
RequestFree(UsbRequest & request)329 int32_t UsbSrvClient::RequestFree(UsbRequest &request)
330 {
331     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
332     const USBDevicePipe &pipe = request.GetPipe();
333     const USBEndpoint &ep = request.GetEndpoint();
334     return proxy_->RequestCancel(pipe.GetBusNum(), pipe.GetDevAddr(), ep.GetInterfaceId(), ep.GetAddress());
335 }
336 
RequestAbort(UsbRequest & request)337 int32_t UsbSrvClient::RequestAbort(UsbRequest &request)
338 {
339     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
340     const USBDevicePipe &pipe = request.GetPipe();
341     const USBEndpoint &ep = request.GetEndpoint();
342     return proxy_->RequestCancel(pipe.GetBusNum(), pipe.GetDevAddr(), ep.GetInterfaceId(), ep.GetAddress());
343 }
344 
RequestQueue(UsbRequest & request)345 int32_t UsbSrvClient::RequestQueue(UsbRequest &request)
346 {
347     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
348     const USBDevicePipe &pipe = request.GetPipe();
349     const USBEndpoint &ep = request.GetEndpoint();
350     const UsbDev tdev = {pipe.GetBusNum(), pipe.GetDevAddr()};
351     const UsbPipe tpipe = {ep.GetInterfaceId(), ep.GetAddress()};
352     return proxy_->RequestQueue(tdev, tpipe, request.GetClientData(), request.GetReqData());
353 }
354 
RegBulkCallback(USBDevicePipe & pip,const USBEndpoint & endpoint,const sptr<IRemoteObject> & cb)355 int32_t UsbSrvClient::RegBulkCallback(USBDevicePipe &pip, const USBEndpoint &endpoint, const sptr<IRemoteObject> &cb)
356 {
357     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
358     const UsbDev tdev = {pip.GetBusNum(), pip.GetDevAddr()};
359     const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
360     int32_t ret = proxy_->RegBulkCallback(tdev, tpipe, cb);
361     if (ret != UEC_OK) {
362         USB_HILOGE(MODULE_USB_INNERKIT, "failed width ret = %{public}d !", ret);
363     }
364     return ret;
365 }
366 
UnRegBulkCallback(USBDevicePipe & pip,const USBEndpoint & endpoint)367 int32_t UsbSrvClient::UnRegBulkCallback(USBDevicePipe &pip, const USBEndpoint &endpoint)
368 {
369     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
370     const UsbDev tdev = {pip.GetBusNum(), pip.GetDevAddr()};
371     const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
372     int32_t ret = proxy_->UnRegBulkCallback(tdev, tpipe);
373     if (ret != UEC_OK) {
374         USB_HILOGE(MODULE_USB_INNERKIT, "failed width ret = %{public}d !", ret);
375     }
376     return ret;
377 }
378 
BulkRead(USBDevicePipe & pip,const USBEndpoint & endpoint,sptr<Ashmem> & ashmem)379 int32_t UsbSrvClient::BulkRead(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr<Ashmem> &ashmem)
380 {
381     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
382     const UsbDev tdev = {pip.GetBusNum(), pip.GetDevAddr()};
383     const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
384     int32_t ret = proxy_->BulkRead(tdev, tpipe, ashmem);
385     if (ret != UEC_OK) {
386         USB_HILOGE(MODULE_USB_INNERKIT, "failed width ret = %{public}d !", ret);
387     }
388     return ret;
389 }
390 
BulkWrite(USBDevicePipe & pip,const USBEndpoint & endpoint,sptr<Ashmem> & ashmem)391 int32_t UsbSrvClient::BulkWrite(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr<Ashmem> &ashmem)
392 {
393     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
394     const UsbDev tdev = {pip.GetBusNum(), pip.GetDevAddr()};
395     const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
396     int32_t ret = proxy_->BulkWrite(tdev, tpipe, ashmem);
397     if (ret != UEC_OK) {
398         USB_HILOGE(MODULE_USB_INNERKIT, "failed width ret = %{public}d !", ret);
399     }
400     return ret;
401 }
402 
BulkCancel(USBDevicePipe & pip,const USBEndpoint & endpoint)403 int32_t UsbSrvClient::BulkCancel(USBDevicePipe &pip, const USBEndpoint &endpoint)
404 {
405     RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
406     const UsbDev tdev = {pip.GetBusNum(), pip.GetDevAddr()};
407     const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
408     int32_t ret = proxy_->BulkCancel(tdev, tpipe);
409     if (ret != UEC_OK) {
410         USB_HILOGE(MODULE_USB_INNERKIT, "failed width ret = %{public}d !", ret);
411     }
412     return ret;
413 }
414 
AddRight(const std::string & bundleName,const std::string & deviceName)415 int32_t UsbSrvClient::AddRight(const std::string &bundleName, const std::string &deviceName)
416 {
417     RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
418     USB_HILOGI(MODULE_USB_INNERKIT, "Calling AddRight");
419     int32_t ret = proxy_->AddRight(bundleName, deviceName);
420     if (ret != UEC_OK) {
421         USB_HILOGE(MODULE_USB_INNERKIT, "failed ret = %{public}d!", ret);
422     }
423     return ret;
424 }
425 } // namespace USB
426 } // namespace OHOS
427