>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
## Modules to import:
```
import deviceManager from '@ohos.distributedHardware.deviceManager';
<td class="cellrowborder" valign="top" width="54.02%" headers="mcps1.1.5.1.4 "><p id="p69671631796"><a name="p69671631796"></a><a name="p69671631796"></a>Bundle name of the application.</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p167001015104813"><aname="p167001015104813"></a><aname="p167001015104813"></a>The device is online.</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p1885516471376"><aname="p1885516471376"></a><aname="p1885516471376"></a>The device is ready, and the device information has been synchronized.</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p205289373811"><aname="p205289373811"></a><aname="p205289373811"></a>The device is offline.</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p15721234163815"><aname="p15721234163815"></a><aname="p15721234163815"></a>The device information is changed.</p>
Creates a **DeviceManager** instance to obtain information about trusted devices and local devices. Before calling any method in **DeviceManager**, you must use **createDeviceManager** to create a **DeviceManager** instance, for example, **dmInstance**.
| deviceId | number | Yes| Unique device identifier.|
| deviceName | string | Yes| Device name.|
| deviceType | number | Yes| Device type.|
## DeviceManager
Provides APIs to obtain information about trusted devices and local devices. Before calling any API in **DeviceManager**, you must use **createDeviceManager** to create a **DeviceManager** instance, for example, **dmInstance**.
### release
release(): void
Releases the **DeviceManager** instance that is no longer used.
<td class="cellrowborder" valign="top" width="56.12561256125613%" headers="mcps1.1.5.1.4 "><p id="p1943935141916"><a name="p1943935141916"></a><a name="p1943935141916"></a>Event type. The value is <strong id="b1279168134313"><a name="b1279168134313"></a><a name="b1279168134313"></a>deviceStateChange</strong>, which indicates a device state change event.</p>
<td class="cellrowborder" valign="top" width="56.12561256125613%" headers="mcps1.1.5.1.4 "><p id="p11232154133112"><a name="p11232154133112"></a><a name="p11232154133112"></a>Callback invoked to return the device information and state.</p>
| type | string | Yes| Event type. The value is **deviceStateChange**, which indicates a device state change event.|
| callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | Yes| Callback invoked to return the device information and state.|
<td class="cellrowborder" valign="top" width="49.81498149814981%" headers="mcps1.1.5.1.4 "><p id="p1879312503335"><a name="p1879312503335"></a><a name="p1879312503335"></a>Event type. The value <strong id="b10256255145015"><a name="b10256255145015"></a><a name="b10256255145015"></a>deviceStateChange</strong> indicates an event of device state change.</p>
<td class="cellrowborder" valign="top" width="49.81498149814981%" headers="mcps1.1.5.1.4 "><p id="p142116971010"><a name="p142116971010"></a><a name="p142116971010"></a>Callback used to return the device state changes.</p>
| type | string | Yes| Event type. The value **deviceStateChange** indicates an event of device state change.|
| callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | Yes| Callback invoked to return the device information and state.|
<td class="cellrowborder" valign="top" width="53.21532153215321%" headers="mcps1.1.5.1.4 "><p id="p291417464617"><a name="p291417464617"></a><a name="p291417464617"></a>Event type. The value <strong id="b1040503814298"><a name="b1040503814298"></a><a name="b1040503814298"></a>serviceDie</strong> indicates an event reported when the <strong id="b11215122991019"><a name="b11215122991019"></a><a name="b11215122991019"></a>DeviceManager</strong> service is terminated unexpectedly.</p>
<td class="cellrowborder" valign="top" width="53.21532153215321%" headers="mcps1.1.5.1.4 "><p id="p1391704610616"><a name="p1391704610616"></a><a name="p1391704610616"></a>Callback invoked when a dead event of the <strong id="b383916403128"><a name="b383916403128"></a><a name="b383916403128"></a>DeviceManager</strong> service occurs.</p>
| type | string | Yes| Event type. The value **serviceDie** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.|
| callback | () => void | Yes| Callback invoked when a dead event of the **DeviceManager** service occurs.|
- Example
```
dmInstance.on("serviceDie", () => {
console.info("serviceDie on");
...
...
@@ -403,54 +190,24 @@ Subscribes to dead events of the **DeviceManager** service.
<td class="cellrowborder" valign="top" width="49.81498149814981%" headers="mcps1.1.5.1.4 "><p id="p1319225511135"><a name="p1319225511135"></a><a name="p1319225511135"></a>Event type. The value <strong id="b174417818132"><a name="b174417818132"></a><a name="b174417818132"></a>serviceDie</strong> indicates an event reported when the <strong id="b7501288133"><a name="b7501288133"></a><a name="b7501288133"></a>DeviceManager</strong> service is terminated unexpectedly.</p>
<td class="cellrowborder" valign="top" width="49.81498149814981%" headers="mcps1.1.5.1.4 "><p id="p176817315398"><a name="p176817315398"></a><a name="p176817315398"></a>Callback used to return the dead event of the <strong id="b1519912196133"><a name="b1519912196133"></a><a name="b1519912196133"></a>DeviceManager</strong> service.</p>
| type | string | Yes| Event type. The value **serviceDie** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.|
| callback | () => void | No| Callback used to return the dead event of the **DeviceManager** service.|