1# USB子系统变更说明 2 3## cl.USB .1 USB管理功能模块接口废弃 4 5**访问级别** 6 7系统接口 8 9**废弃原因** 10 11USB模块接口增加权限控制,新开放的接口包含旧的系统级接口完整功能,接口更加标准并且原子化,符合社区API规范。 12 13**废弃影响** 14 15非兼容性变更,需要开发者进行适配。 16 17**废弃发生版本** 18 19从OpenHarmony SDK 4.1.5.1开始。 20 21**废弃的接口** 22 23修改不合理的鉴权方式整改。不允许使用调用方进程APL等级进行权限校验,需要修改为使用AccessTokenKit::VerifyAccessToken对访问者进行权限校验,新接口调用者需要申请ohos.permission. MANAGE_USB_CONFIG权限。 24| 接口声明 | 废弃说明 | 替代接口 | 25| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | 26| function addRight(bundleName: string, deviceName: string): boolean; | 使用usb.addDeviceAccessRight接口添加软件包访问设备的权限。 | function addDeviceAccessRight(bundleName: string, deviceName: string): boolean; | 27| function usbFunctionsFromString(funcs: string): number; | 使用usb.getFunctionsFromString接口将字符串形式的USB功能列表转化为数字掩码 | function getFunctionsFromString(funcs: string): number; | 28| function usbFunctionsToString(funcs: FunctionType): string; | 使用usb.convertFunctionsToString接口将数字掩码形式的USB功能列表转化为字符串。 | function convertFunctionsToString(funcs: FunctionType): string; | 29| function setCurrentFunctions(funcs: FunctionType): Promise<void>; | 使用usb.setDeviceFunctions接口设置当前的USB功能列表。 | function setDeviceFunctions(funcs: FunctionType): Promise<void>; | 30| function getCurrentFunctions(): FunctionType; | 使用usb.getDeviceFunctions接口获取当前的USB功能列表的数字组合掩码。 | function getDeviceFunctions(): FunctionType; | 31| function getPorts(): Array<USBPort>; | 使用usb.getUsbPorts接口获取所有物理USB端口描述信息。 | function getUsbPorts(): Array<USBPort>; | 32| function getSupportedModes(portId: number): PortModeType; | 使用usb.getUsbPortSupportModes接口获取指定的端口支持的模式列表的组合掩码 | function getUsbPortSupportModes(portId: number): PortModeType; | 33| function setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise<void>; | 使用usb.setUsbPortRoles接口设置指定的端口支持的角色模式,包含充电角色、数据传输角色。 | function setUsbPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise<void>; | 34 35**适配指导** 36 37变更前 38应用配置文件xxx.cfg中的apl字段是system_basic 或者 system_core。 39变更后 40配置文件中的permission 字段需要添加ohos.permission.MANAGE_USB_CONFIG权限。 41