From cefc688bbf8a36bc6b28dd4ffa4cebfb9c9828ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sun, 25 Jun 2023 16:58:05 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90dm=E3=80=91=E6=B7=BB=E5=8A=A0=E5=8C=97?= =?UTF-8?q?=E5=90=91=E6=8E=A5=E5=8F=A3=E9=81=97=E6=BC=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../apis/js-apis-distributedDeviceManager.md | 54 ++++++++++++++++++ .../changelogs-distributedDeviceManager.md | 57 +++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-distributedDeviceManager.md diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributedDeviceManager.md b/zh-cn/application-dev/reference/apis/js-apis-distributedDeviceManager.md index d0648bf783..6c2866277f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributedDeviceManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributedDeviceManager.md @@ -1121,6 +1121,60 @@ off(type: 'discoverSuccess', callback?: Callback<{ subscribeId: number, device: } ``` +### on('deviceNameChange') + +on(type: 'deviceNameChange', callback: Callback<{ deviceName: string }>): void; + +注册设备名称改变回调监听。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------------- | ---- | ------------------------------ | + | type | string | 是 | 注册设备名称改变回调,以便在设备名称改变时通知应用程序。 | + | callback | Callback<{ deviceName: string}> | 是 | 注册设备名称改变的回调方法。 | + +**示例:** + + ```js + try { + dmInstance.on('deviceNameChange', (data) => { + console.info("deviceNameChange on:" + JSON.stringify(data)); + }); + } catch (err) { + console.error("deviceNameChange errCode:" + err.code + ",errMessage:" + err.message); + } + ``` + +### off('deviceNameChange') + +off(type: 'deviceNameChange', callback?: Callback<{ deviceName: string }>): void; + +取消注册设备名称改变回调监听。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------------- | ---- | ------------------------------ | + | type | string | 是 | 取消注册设备名称改变回调。 | + | callback | Callback<{ deviceName: string}> | 否 | 指示要取消注册设备名称改变的回调方法。 | + +**示例:** + + ```js + try { + dmInstance.off('deviceNameChange', (data) => { + console.info('deviceNameChange' + JSON.stringify(data)); + }); + } catch (err) { + console.error("deviceNameChange errCode:" + err.code + ",errMessage:" + err.message); + } + ``` + ### on('discoverFail') on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: number }>): void diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-distributedDeviceManager.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-distributedDeviceManager.md new file mode 100644 index 0000000000..614ce0ce76 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-distributedDeviceManager.md @@ -0,0 +1,57 @@ +# 设备管理ChangeLog +## cl.distributedDeviceManager.1 接口变更 + +从Opeharmonny 4.0.9.2版本开始,新增了设备管理接口,部分接口仅系统应用可调用。 + +**变更影响** + +原有的接口暂时可继续使用,但是停止维护,建议使用新接口进行开发。 + +**关键的接口/组件变更** + +##新增接口如下: + +| 模块名 | 类名 | 新增接口声明 | 是否支持三方应用调用 | +| ------------------------- | ------------------- | ------------------------------------------------------------ | ------------------------------- | +| @ohos.distributedDeviceManager | deviceManager | **function** createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager>): void | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** releaseDeviceManager(): void | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** getAvailableDeviceListSync(): Array<DeviceBasicInfo> | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** getAvailableDeviceList(callback:AsyncCallback<Array<DeviceBasicInfo>>): void | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** getAvailableDeviceList(): Promise<Array<DeviceBasicInfo>> | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** getLocalDeviceNetworkIdSync(): string | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** getLocalDeviceNameSync(): string | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** getLocalDeviceTypeSync(): number | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** getLocalDeviceIdSync(): string | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** getDeviceNameSync(networkId: string): string; | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** getDeviceTypeSync(networkId: string): number; | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** startDeviceDiscovery(subscribeId: number, filterOptions?: string): void; | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** stopDeviceDiscovery(subscribeId: number): void | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** bindDevice(deviceId: string, bindParam: BindParam, callback: AsyncCallback<{deviceId: string}>): void; | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** unbindDevice(deviceId: string): void; | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** publishDeviceDiscovery(publishInfo: PublishInfo): void | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** unPublishDeviceDiscovery(publishId: number): void | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, level: number}>): void | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** setUserOperation(operateAction: number, params: string): void; | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback<{registerInfo: string}>): void; | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** importCredential(credentialInfo: string, callback: AsyncCallback<{resultInfo: string}>): void; | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** deleteCredential(queryInfo: string, callback: AsyncCallback<{resultInfo: string}>): void; | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** on(type: 'deviceStatusChange', callback: Callback<{ action: DeviceStatusChange, device: DeviceBasicInfo }>): void; | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** off(type: 'deviceStatusChange', callback?: Callback<{ action: DeviceStatusChange, device: DeviceBasicInfo }>): void; | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** on(type: 'discoverSuccess', callback: Callback<{ subscribeId: number, device: DeviceBasicInfo }>): void; | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** off(type: 'discoverSuccess', callback?: Callback<{ subscribeId: number, device: DeviceBasicInfo }>): void; | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** on(type: 'deviceNameChange', callback: Callback<{ deviceName: string }>): void; | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** off(type: 'deviceNameChange', callback?: Callback<{ deviceName: string }>): void; | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: number }>): void | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: number }>): void | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** on(type: 'serviceDie', callback: () => void): void | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** off(type: 'serviceDie', callback?: () => void): void | 是 | +| @ohos.distributedDeviceManager | deviceManager | **function** on(type: 'uiStateChange', callback: Callback<{ param: string}>): void; | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void; | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): void | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): void | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** on(type: 'publishFail', callback: Callback<{ publishId: number, reason: number }>): void | 否 | +| @ohos.distributedDeviceManager | deviceManager | **function** off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: number }>): void | 否 | + +**适配指导** + +请参考各接口的[API参考](../../../application-dev/reference/apis/js-apis-distributedDeviceManager.md) -- GitLab