• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# USB Subsystem Changelog
2
3## cl.usbManager.1 Change of Error Code from 202 to 201 for Calling a System API When the ohos.permission.MANAGE_USB_CONFIG Permission Is Missing
4
5**Access Level**
6
7System API
8
9**Reason for the Change**
10
11When the system API is called, the **ohos.permission.MANAGE_USB_CONFIG** permission must be added to the **permission** field in the system application configuration file. If the permission is not configured, error code 201 is returned.
12
13**Change Impact**
14
15This change is a non-compatible change.
16
17The following is an example:
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
43Before change: When the system application calls a system API, if the **ohos.permission.MANAGE_USB_CONFIG** permission is not configured in the **permission** field in the configuration file, error code 202 is returned.
44
45After change: When the system application calls a system API, if the **ohos.permission.MANAGE_USB_CONFIG** permission is not configured in the **permission** field in the configuration file, error code 201 is returned.
46
47**Start API Level**
48
4912
50
51**Change Since**
52
53OpenHarmony SDK 5.1.0.45 and later versions
54
55**Key API/Component Changes**
56
57|            API           |               Description              |
58| :----------------------------: | :----------------------------------: |
59| addDeviceAccessRight(tokenId: string, deviceName: string): boolean | Added error code 201.|
60| getFunctionsFromString(funcs: string): number | Added error code 201.|
61| getStringFromFunctions(funcs: FunctionType): string | Added error code 201.|
62| setDeviceFunctions(funcs: FunctionType): Promise\<void> | Added error code 201.|
63| getDeviceFunctions(): FunctionType | Added error code 201.|
64| getPortList(): Array\<USBPort> | Added error code 201.|
65| getPortSupportModes(portId: number): PortModeType | Added error code 201.|
66| setPortRoleTypes(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise\<void> | Added error code 201.|
67
68
69**Adaptation Guide**
70
71Add error code 201 for the system application to call system APIs when the **ohos.permission.MANAGE_USB_CONFIG** permission is not configured in the **permission** field in the system application configuration file.
72