From 0adff9f26739044b5daa9073b218219aad751ddc Mon Sep 17 00:00:00 2001 From: luo-wei246 Date: Thu, 22 Dec 2022 11:26:39 +0800 Subject: [PATCH] fixed 7b395d1 from https://gitee.com/ge-yafang/docs/pulls/12758 fix:USB document update Signed-off-by: luo-wei246 --- zh-cn/application-dev/device/usb-guidelines.md | 12 ++++++------ zh-cn/application-dev/reference/apis/js-apis-usb.md | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/zh-cn/application-dev/device/usb-guidelines.md b/zh-cn/application-dev/device/usb-guidelines.md index 5ae59b9f4e..e21409b651 100644 --- a/zh-cn/application-dev/device/usb-guidelines.md +++ b/zh-cn/application-dev/device/usb-guidelines.md @@ -17,17 +17,17 @@ USB类开放能力如下,具体请查阅[API参考文档](../reference/apis/js | 接口名 | 描述 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| hasRight(deviceName: string): boolean | 如果“使用者”(如各种App或系统)有权访问设备则返回true;无权访问设备则返回false。 | -| requestRight(deviceName: string): Promise<boolean> | 请求给定软件包的临时权限以访问设备。 | +| hasRight(deviceName: string): boolean | 判断是否有权访问该设备 | +| requestRight(deviceName: string): Promise<boolean> | 请求软件包的临时权限以访问设备。使用Promise异步回调。 | | removeRight(deviceName: string): boolean | 移除软件包对设备的访问权限。| | connectDevice(device: USBDevice): Readonly<USBDevicePipe> | 根据`getDevices()`返回的设备信息打开USB设备。 | -| getDevices(): Array<Readonly<USBDevice>> | 返回USB设备列表。 | +| getDevices(): Array<Readonly<USBDevice>> | 获取接入主设备的USB设备列表。如果没有设备接入,那么将会返回一个空的列表。 | | setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | 设置设备的配置。 | | setInterface(pipe: USBDevicePipe, iface: USBInterface): number | 设置设备的接口。 | -| claimInterface(pipe: USBDevicePipe, iface: USBInterface,force?: boolean): number | 获取接口。 | +| claimInterface(pipe: USBDevicePipe, iface: USBInterface,force?: boolean): number | 注册通信接口。 | | bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise<number> | 批量传输。 | | closePipe(pipe: USBDevicePipe): number | 关闭设备消息控制通道。 | -| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | 释放接口。 | +| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | 释放注册过的通信接口。 | | getFileDescriptor(pipe: USBDevicePipe): number | 获取文件描述符。 | | getRawDescriptor(pipe: USBDevicePipe): Uint8Array | 获取原始的USB描述符。 | | controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise<number> | 控制传输。 | @@ -42,7 +42,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ```js // 导入USB接口api包。 - import usb from '@ohos.usb'; + import usb from '@ohos.usbV9'; // 获取设备列表。 let deviceList = usb.getDevices(); /* diff --git a/zh-cn/application-dev/reference/apis/js-apis-usb.md b/zh-cn/application-dev/reference/apis/js-apis-usb.md index a13cf74421..d0331a03cd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-usb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-usb.md @@ -87,7 +87,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`); connectDevice(device: USBDevice): Readonly<USBDevicePipe> -打开USB设备。 +根据getDevices()返回的设备信息打开USB设备。 需要调用[usb.getDevices](#usbgetdevices)获取设备信息以及device,再调用[usb.requestRight](#usbrequestright)请求使用该设备的权限。 @@ -134,6 +134,8 @@ hasRight(deviceName: string): boolean 判断是否有权访问该设备。 +如果“使用者”(如各种App或系统)有权访问设备则返回true;无权访问设备则返回false。 + **系统能力:** SystemCapability.USB.USBManager **参数:** @@ -187,7 +189,7 @@ usb.requestRight(devicesName).then((ret) => { ## usb.removeRight -removeRight(deviceName: string): boolean; +removeRight(deviceName: string): boolean 移除软件包访问设备的权限。 @@ -216,7 +218,7 @@ if (usb.removeRight(devicesName) { ## usb.addRight -addRight(bundleName: string, deviceName: string): boolean; +addRight(bundleName: string, deviceName: string): boolean 添加软件包访问设备的权限。 -- GitLab