From 8fd482e6fe992beb2510ca3aafe577a11288684f Mon Sep 17 00:00:00 2001 From: Gloria Date: Sat, 25 Feb 2023 14:53:22 +0800 Subject: [PATCH] Update docs against 14069 Signed-off-by: wusongqing --- .../reference/apis/js-apis-device-manager.md | 100 +++++------------- 1 file changed, 28 insertions(+), 72 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-device-manager.md b/en/application-dev/reference/apis/js-apis-device-manager.md index e8363f6203..22f2bda152 100644 --- a/en/application-dev/reference/apis/js-apis-device-manager.md +++ b/en/application-dev/reference/apis/js-apis-device-manager.md @@ -249,8 +249,6 @@ getTrustedDeviceListSync(): Array<DeviceInfo> Obtains all trusted devices synchronously. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Return value** @@ -283,8 +281,6 @@ getTrustedDeviceList(callback:AsyncCallback<Array<DeviceInfo>>): voi Obtains all trusted devices. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -323,8 +319,6 @@ getTrustedDeviceList(): Promise<Array<DeviceInfo>> Obtains all trusted devices. This API uses a promise to return the result. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Return value** @@ -357,8 +351,6 @@ getLocalDeviceInfoSync(): [DeviceInfo](#deviceinfo) Obtains local device information synchronously. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Return value** @@ -391,8 +383,6 @@ getLocalDeviceInfo(callback:AsyncCallback<DeviceInfo>): void Obtains local device information. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -431,8 +421,6 @@ getLocalDeviceInfo(): Promise<DeviceInfo> Obtains local device information. This API uses a promise to return the result. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Return value** @@ -465,8 +453,6 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void Starts to discover peripheral devices. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -511,8 +497,6 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void Starts to discover peripheral devices and filters discovered devices. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -567,8 +551,6 @@ stopDeviceDiscovery(subscribeId: number): void Stops device discovery. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -588,8 +570,9 @@ For details about the error codes, see [Device Management Error Codes](../errorc **Example** ```js - // The subscribeId input must be the same as that automatically generated in startDeviceDiscovery. try { + // stopDeviceDiscovery and startDeviceDiscovery must be used in pairs, and the input parameter **subscribeId** passed in them must be the same. + var subscribeId = 12345; dmInstance.stopDeviceDiscovery(subscribeId); } catch (err) { console.error("stopDeviceDiscovery errCode:" + err.code + ",errMessage:" + err.message); @@ -602,8 +585,6 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void Publishes device information for discovery purposes. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -630,7 +611,7 @@ For details about the error codes, see [Device Management Error Codes](../errorc "publishId": publishId, "mode": 0xAA, // Active discovery "freq": 2, // High frequency - "ranging": 1 // The device supports reporting the distance to the discovery initiator. + "ranging": true // The device supports reporting the distance to the discovery initiator. }; try { dmInstance.publishDeviceDiscovery(publishInfo); // A callback is invoked to notify the application when the device information is published. @@ -638,15 +619,13 @@ For details about the error codes, see [Device Management Error Codes](../errorc console.error("publishDeviceDiscovery errCode:" + err.code + ",errMessage:" + err.message); } ``` - + ### unPublishDeviceDiscovery9+ unPublishDeviceDiscovery(publishId: number): void Stops publishing device information. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -666,8 +645,9 @@ For details about the error codes, see [Device Management Error Codes](../errorc **Example** ```js - // The publishId input must be the same as that automatically generated in publishDeviceDiscovery. try { + // unPublishDeviceDiscovery and publishDeviceDiscovery must be used in pairs, and the input parameter **publishId** passed in them must be the same. + var publishId = 12345; dmInstance.unPublishDeviceDiscovery(publishId); } catch (err) { console.error("unPublishDeviceDiscovery errCode:" + err.code + ",errMessage:" + err.message); @@ -680,8 +660,6 @@ authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: Async Authenticates a device. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -708,11 +686,19 @@ For details about the error codes, see [Device Management Error Codes](../errorc var deviceInfo ={ "deviceId": "XXXXXXXX", "deviceName": "", - deviceType: 0x0E + "deviceType": 0x0E, + "networkId" : "xxxxxxx", + "range" : 0 }; + let extraInfo = { + 'targetPkgName': 'ohos.samples.xxx', + 'appName': 'xxx', + 'appDescription': 'xxx', + 'business': '0' + } let authParam = { - "authType": 1, // Authentication type. The value 1 means no account PIN authentication. - "extraInfo": {} + 'authType': 1, // Authentication type. The value 1 means no account PIN authentication. + 'extraInfo': extraInfo } try { dmInstance.authenticateDevice(deviceInfo, authParam, (err, data) => { @@ -734,8 +720,6 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void Deauthenticates a device. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -756,6 +740,13 @@ For details about the error codes, see [Device Management Error Codes](../errorc ```js try { + var deviceInfo ={ + "deviceId": "XXXXXXXX", + "deviceName": "", + "deviceType": 0x0E, + "networkId" : "xxxxxxx", + "range" : 0 + }; dmInstance.unAuthenticateDevice(deviceInfo); } catch (err) { console.error("unAuthenticateDevice errCode:" + err.code + ",errMessage:" + err.message); @@ -768,8 +759,6 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, Verifies authentication information. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -792,7 +781,7 @@ For details about the error codes, see [Device Management Error Codes](../errorc ```js let authInfo = { "authType": 1, - "token": xxxxxx, + "token": 123456, "extraInfo": {} } try { @@ -814,8 +803,6 @@ setUserOperation(operateAction: number, params: string): void; Sets a user operation. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -838,7 +825,7 @@ Sets a user operation. operateAction = 5 - Confirm the input in the PIN input box. */ let operation = 0; - this.dmInstance.setUserOperation(operation, "extra") + dmInstance.setUserOperation(operation, "extra") } catch (err) { console.error("setUserOperation errCode:" + err.code + ",errMessage:" + err.message); } @@ -850,8 +837,6 @@ on(type: 'uiStateChange', callback: Callback<{ param: string}>): void; Subscribes to UI status changes. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -868,11 +853,8 @@ Subscribes to UI status changes. dmInstance.on('uiStateChange', (data) => { console.log("uiStateChange executed, dialog closed" + JSON.stringify(data)) var tmpStr = JSON.parse(data.param) - this.isShow = tmpStr.verifyFailed - console.log("uiStateChange executed, dialog closed" + this.isShow) - if (!this.isShow) { - this.destruction() - } + var isShow = tmpStr.verifyFailed + console.log("uiStateChange executed, dialog closed" + isShow) }); } catch (err) { console.error("uiStateChange errCode:" + err.code + ",errMessage:" + err.message); @@ -885,8 +867,6 @@ off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void; Unsubscribes from UI status changes. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -912,8 +892,6 @@ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange Subscribes to changes in the device state. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -941,8 +919,6 @@ off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChang Unsubscribes from changes in the device state. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -970,8 +946,6 @@ on(type: 'deviceFound', callback: Callback<{ subscribeId: number, device: Dev Subscribes to device discovery events. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -999,8 +973,6 @@ off(type: 'deviceFound', callback?: Callback<{ subscribeId: number, device: D Unsubscribes from device discovery events. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1028,8 +1000,6 @@ on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: nu Subscribes to device discovery failures. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1057,8 +1027,6 @@ off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: Unsubscribes from device discovery failures. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1086,8 +1054,6 @@ on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): voi Subscribes to device information publication success events. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1116,8 +1082,6 @@ off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): v Unsubscribes from device information publication success events. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1145,8 +1109,6 @@ on(type: 'publishFail', callback: Callback<{ publishId: number, reason: numbe Subscribes to device information publication failures. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1174,8 +1136,6 @@ off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: num Unsubscribes from device information publication failures. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1203,8 +1163,6 @@ on(type: 'serviceDie', callback: () => void): void Subscribes to dead events of the **DeviceManager** service. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1232,8 +1190,6 @@ off(type: 'serviceDie', callback?: () => void): void Unsubscribes from dead events of the **DeviceManager** service. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** -- GitLab