The **deviceManager** module provides APIs for distributed device management.
Applications can call the APIs to:
- Subscribe to or unsubscribe from device state changes.
- Discover untrusted devices nearby.
- Authenticate or deauthenticate a device.
- Query the trusted device list.
- Query local device information, including the device name, type, and ID.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Creates a **DeviceManager** instance. The **DeviceManager** instance is the entry for invoking the APIs for distributed device management. It can be used to obtain information about trusted devices and local devices.
| UNKNOWN | 0 | The device state is unknown after the device goes online. Before the device state changes to available, distributed services cannot be used. |
| AVAILABLE | 1 | The information between devices has been synchronized in the Distributed Data Service (DDS) module, and the device is ready for running distributed services.|
| UNAVAILABLE | 2 | The device goes offline, and the device state is unknown. |
## 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**.
| discoverParam | {[key: string]: Object} | Yes | Identifier of the device to discover. It specifies the type of the target to discover.<br>**discoverTargetType**: The default discovery target is device. The value is **1**.|
| filterOptions | {[key: string]: Object} | No | Options for filtering discovered devices. The default value is **undefined**, which means to discover offline devices. The following **key** values are carried:<br>**availableStatus(0-1)**: Discover trusted devices only. The value **0** indicates that the device is untrusted.<br>- **0**: The device is offline. The client needs to call **bindTarget** to bind the device.<br>- **1**: The device is online and can be connected.<br>**discoverDistance(0-100)**: Discover devices within a certain distance (in cm) from the local device.<br>**authenticationStatus(0-1)**: Discover devices based on the authentication status.<br>- **0**: The device is not authenticated.<br>- **1**: The device has been authenticated.<br>**authorizationType(0-2)**: Discover devices based on the authorization type.<br>- **0**: device authenticated by a temporarily agreed session key.<br>- **1**: device authenticated by a key of the same account.<br>- **2**: devices authenticated by a credential key of different accounts.|
**Error codes**
For details about the error codes, see [Device Management Error Codes](../errorcodes/errorcode-device-manager.md).
| bindParam | {[key: string]: Object} | Yes | Authentication parameters. You can determine the key-value pair to be passed in. By default, the following **key** values are carried:<br>**bindType**: binding type.<br>- **1**: PIN.<br>- **2**: QR code.<br>- 3: NFC.<br>- 4: No interaction.<br>**targetPkgName**: bundle name of the target to bind.<br>**appName**: application that attempts to bind the target.<br>**appOperation**: reason for the application to bind the target.<br>**customDescription**: detailed description of the operation. |
| callback | AsyncCallback<{deviceId: string, }> | Yes | Callback invoked to return the authentication result.|
**Error codes**
For details about the error codes, see [Device Management Error Codes](../errorcodes/errorcode-device-manager.md).
| type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event.|
| callback | Callback<{ action: [DeviceStateChange](#devicestatechange), device: [DeviceBasicInfo](#devicebasicinfo) }> | Yes | Callback invoked to return the device information and state. |
| type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event. |
| callback | Callback<{ action: [deviceStateChange](#devicestatechange), device: [DeviceBasicInfo](#devicebasicinfo) }> | No | Callback for the device information and state.|
| type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.|
| callback | Callback<{}> | No | Callback invoked when a dead event of the **DeviceManager** service occurs. |
| type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.|
| callback | Callback<{}> | No | Callback for the dead event of the **DeviceManager** service. |
The **browser** module provides browser management, including setting, deleting, and obtaining browser policies.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
>
> The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
| appId | string | Yes | Application ID, which is used to specify the browser. |
| policies | string | Yes | Policies to set. If this parameter is set to an empty string, the policies of the specified browser will be deleted. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
Obtains the policies of a given browser through the specified device administrator application. This API uses an asynchronous callback to return the result.
| appId | string | Yes | Application ID, which is used to specify the browser. |
| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).