1# USB服务子系统Changelog 2 3## cl.usbManager.1 @ohos.usbManager 当系统应用未添加ohos.permission.MANAGE_USB_CONFIG权限时调用系统API接口返回错误码从202变更为201 4 5**访问级别** 6 7系统接口。 8 9**变更原因** 10 11当调用系统API接口时:系统应用配置文件中的permission字段需要添加ohos.permission.MANAGE_USB_CONFIG权限才可以有权限访问系统API接口,如果未配置权限需要返回201错误码。 12 13**变更影响** 14 15该变更为不兼容变更。 16 17举例说明,执行以下用例: 18 19```ts 20import { usbManager } from '@kit.BasicServicesKit'; 21import { bundleManager } from '@kit.AbilityKit'; 22import { BusinessError } from '@kit.BasicServicesKit'; 23let devicesName: string = "1-1"; 24let tokenId: string = ""; 25 26 try { 27 let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; 28 bundleManager.getBundleInfoForSelf(bundleFlags).then((bundleInfo) => { 29 console.info('testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(bundleInfo)); 30 let token = bundleInfo.appInfo.accessTokenId; 31 tokenId = token.toString(); 32 if (usbManager.addDeviceAccessRight(tokenId, devicesName)) { 33 console.log(`Succeed in adding right`); 34 } 35 }).catch((err : BusinessError) => { 36 console.error('testTag getBundleInfoForSelf failed' ); 37 }); 38 } catch (err) { 39 console.error('testTag failed'); 40 } 41``` 42 43变更前:系统应用未在配置文件中的permission字段添加ohos.permission.MANAGE_USB_CONFIG权限时,调用系统API接口返回202错误码。 44 45变更后:系统应用未在配置文件中的permission字段添加ohos.permission.MANAGE_USB_CONFIG权限时,调用系统API接口返回201错误码。 46 47**起始 API Level** 48 4912 50 51**变更-新增发生的版本** 52 53从OpenHarmony SDK 5.1.0.45开始。 54 55**新增错误码的接口/组件** 56 57| 接口声明 | 新增说明 | 58| :----------------------------: | :----------------------------------: | 59| addDeviceAccessRight(tokenId: string, deviceName: string): boolean | 新增201错误码 | 60| getFunctionsFromString(funcs: string): number | 新增201错误码 | 61| getStringFromFunctions(funcs: FunctionType): string | 新增201错误码 | 62| setDeviceFunctions(funcs: FunctionType): Promise\<void> | 新增201错误码 | 63| getDeviceFunctions(): FunctionType | 新增201错误码 | 64| getPortList(): Array\<USBPort> | 新增201错误码 | 65| getPortSupportModes(portId: number): PortModeType | 新增201错误码 | 66| setPortRoleTypes(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise\<void> | 新增201错误码 | 67 68 69**适配指导** 70 71开发者需将使用@ohos.usbManager模块新增错误码的系统接口调用的地方适配新增201错误码提示。