The distributedAccount module provides basic functions for managing distributed accounts, including querying and updating account login status.
The **distributedAccount** module provides APIs for managing distributed accounts, including querying and updating account login status.
> **NOTE**<br>
>
> 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.
@@ -25,7 +24,7 @@ Obtains a **DistributedAccountAbility** instance.
| Type| Description|
| -------- | -------- |
| [DistributedAccountAbility](#distributedaccountability) | **DistributedAccountAbility** instance obtained. This instance provides methods for querying and updating the login state of a distributed account.|
| [DistributedAccountAbility](#distributedaccountability) | **DistributedAccountAbility** instance obtained. This instance provides APIs for querying and updating the login state of a distributed account.|
**Example**
```js
...
...
@@ -34,13 +33,88 @@ Obtains a **DistributedAccountAbility** instance.
## DistributedAccountAbility
Provides methods for querying and updating the login state of a distributed account. You must obtain a **DistributedAccountAbility** instance first.
Provides APIs for querying and updating the login state of a distributed account. You must obtain a **DistributedAccountAbility** instance first.
**Required permissions**: ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS, ohos.permission.GET_DISTRIBUTED_ACCOUNTS, or ohos.permission.DISTRIBUTED_DATASYNC
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and data is the distributed account information obtained. Otherwise, **err** is an error object.|
Obtains distributed account information. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getOsAccountDistributedInfo](#getosaccountdistributedinfo9).
@@ -50,7 +124,7 @@ Obtains distributed account information. This API uses an asynchronous callback
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the distributed account information obtained.|
| callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and data is the distributed account information obtained. Otherwise, **err** is an error object.|
**Example**
```js
...
...
@@ -62,12 +136,16 @@ Obtains distributed account information. This API uses an asynchronous callback
Obtains distributed account information. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getOsAccountDistributedInfo](#getosaccountdistributedinfo9-1).
| accountInfo | [DistributedInfo](#distributedinfo) | Yes| New distributed account information.|
| callback | AsyncCallback<void> | Yes| Callback invoked to return the result. If the distributed account information is set successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
Updates distributed account information. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setOsAccountDistributedInfo](#setosaccountdistributedinfo9).
| callback | AsyncCallback<void> | Yes| Callback invoked when the distributed account information is updated.|
| accountInfo | [DistributedInfo](#distributedinfo) | Yes| New distributed account information.|
| callback | AsyncCallback<void> | Yes| Callback invoked to return the result. If the distributed account information is set successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
...
...
@@ -115,12 +278,14 @@ Updates distributed account information. This API uses an asynchronous callback
Updates distributed account information. This API uses a promise to return the result.
Updates the distributed account information. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setOsAccountDistributedInfo](#setosaccountdistributedinfo9-1).
@@ -157,7 +320,9 @@ Defines distributed OS account information.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of a distributed account. It must be a non-null string.|
| id | string | Yes| UID of a distributed account. It must be a non-null string.|
| name | string | Yes| Name of the distributed account. It must be a non-null string.|
| id | string | Yes| UID of the distributed account. It must be a non-null string.|
| event | string | Yes| Login state of a distributed account. The state can be login, logout, token invalid, or logoff, which correspond to the following strings respectively:<br>- Ohos.account.event.LOGIN<br>- Ohos.account.event.LOGOUT<br>- Ohos.account.event.TOKEN_INVALID<br>- Ohos.account.event.LOGOFF |
| scalableData | object | No| Extended information about a distributed account. Customized information is passed in key-value pairs.<br>Note: This parameter is reserved and not used in query and update methods.|
| nickname<sup>9+</sup> | string | No| Nickname of the distributed account. It must be a non-null string.|
| avatar<sup>9+</sup> | string | No| Avatar of the distributed account. It must be a non-null string.|
| scalableData | object | No| Extended information about the distributed account, passed in key-value (KV) pairs.<br>**NOTE**<br>This parameter is reserved and not used in query and update methods.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, multiple OS accounts are supported. If **false** is returned, multiple OS accounts are not supported.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means multiple OS accounts are supported; the value false means the opposite.|
**Error codes**
...
...
@@ -191,7 +191,7 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re
| Promise<boolean> | Promise used to return the result. If **true** is returned, multiple OS accounts are supported. If **false** is returned, multiple OS accounts are not supported.|
| Promise<boolean> | Promise used to return the result. The value **true** means multiple OS accounts are supported; the value false means the opposite.|
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, the account is activated. If **false** is returned, the account is not activated.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the account is activated; the value **false** means the opposite.|
**Error codes**
...
...
@@ -277,7 +277,7 @@ Checks whether an OS account is activated. This API uses a promise to return the
| Promise<boolean> | Promise used to return the result. If **true** is returned, the account is activated. If **false** is returned, the account is not activated.|
| Promise<boolean> | Promise used to return the result. The value **true** means the account is activated; the value **false** means the opposite.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, the constraint is enabled. If **false** is returned, the constraint is not enabled.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the specified constraint is enabled; the value **false** means the opposite.|
**Error codes**
...
...
@@ -369,7 +369,7 @@ Checks whether the specified constraint is enabled for an OS account. This API u
| Promise<boolean> | Promise used to return the result. If **true** is returned, the constraint is enabled. If **false** is returned, the constraint is not enabled.|
| Promise<boolean> | Promise used to return the result. The value **true** means the specified constraint is enabled; the value **false** means the opposite.|
**Error codes**
...
...
@@ -408,7 +408,7 @@ Checks whether this OS account is a test account. This API uses an asynchronous
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, the account is a test account. If **false** is returned, the account is not a test account.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the account is a test account; the value **false** means the opposite.|
**Error codes**
...
...
@@ -445,7 +445,7 @@ Checks whether this OS account is a test account. This API uses a promise to ret
| Promise<boolean> | Promise used to return the result. If **true** is returned, the account is a test account. If **false** is returned, the account is not a test account.|
| Promise<boolean> | Promise used to return the result. The value **true** means the account is a test account; the value **false** means the opposite.|
**Error codes**
...
...
@@ -482,7 +482,7 @@ Checks whether this OS account has been verified. This API uses an asynchronous
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, the account has been verified. If **false** is returned, the account has not been verified.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If true is returned, the current account has been verified. If false is returned, the current account has not been verified.|
**Error codes**
...
...
@@ -523,8 +523,8 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca
| localId | number | No | ID of the target OS account. |
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, the account has been verified. If **false** is returned, the account has not been verified.|
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the OS account has been verified; the value **false** means the opposite.|
**Error codes**
...
...
@@ -572,7 +572,7 @@ Checks whether an OS account has been verified. This API uses a promise to retur
| Promise<boolean> | Promise used to return the result. If **true** is returned, the account has been verified. If **false** is returned, the account has not been verified.|
| Promise<boolean> | Promise used to return the result. The value **true** means the OS account has been verified; the value **false** means the opposite.|
**Error codes**
...
...
@@ -814,7 +814,7 @@ Sets a name for an OS account. This API uses an asynchronous callback to return
| localId | number | Yes | ID of the target OS account. |
| localName | string | Yes | Account name to set. The value cannot exceed 1024 characters. |
| localName | string | Yes | Account name. The value cannot exceed 1024 characters. |
| 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**
...
...
@@ -1918,7 +1918,7 @@ Obtains the type of the account to which the current process belongs. This API u
getOsAccountType(): Promise<OsAccountType>
Obtains the type of the OS account to which the current process belongs. This API uses a promise to return the result.
Obtains the type of the account to which the current process belongs. This API uses a promise to return the result.
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
| 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**
...
...
@@ -2381,7 +2381,7 @@ Obtains the SN of an OS account based on the account ID. This API uses a promise
Subscribes to OS account changes. This API uses a callback to return the result.
Subscribes to the OS account activation states, including the states of the account being activated and the account with activation completed. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
...
...
@@ -2393,9 +2393,9 @@ Subscribes to OS account changes. This API uses a callback to return the result.
| type | 'activate' \| 'activating' | Yes | Type of the event to subscribe to. The value **activate**means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated.|
| type | 'activate' \| 'activating' | Yes | Type of the event to subscribe to. The value **activate**indicates an event reported when the OS account activation is complete, and **activating** indicates an event reported when OS account is being activated.|
| name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes. |
| callback | Callback<number> | Yes | Callback invoked to return the OS account ID and status changes. |
| callback | Callback<number> | Yes | Callback invoked to return the ID of the OS account being activated or activated. |
**Error codes**
...
...
@@ -2423,7 +2423,7 @@ Subscribes to OS account changes. This API uses a callback to return the result.
Unsubscribes from OS account changes. This API uses a callback to return the result.
Unsubscribes from the OS account activation states, including the states of the account being activated and the account with activation completed. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
...
...
@@ -2437,7 +2437,7 @@ Unsubscribes from OS account changes. This API uses a callback to return the res
| type | 'activate' \| 'activating' | Yes | Type of the event to unsubscribe from. The value **activate** means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated.|
| name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes, and must be the same as the value passed by **on()**.|
| callback | Callback<number> | No | Callback for OS account changes. By default, **0** is returned. |
| callback | Callback<number> | No | Callback to unregister. By default, **0** is returned. |
**Error codes**
...
...
@@ -2725,7 +2725,7 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, multiple OS accounts are supported. If **false** is returned, multiple OS accounts are not supported.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means multiple OS accounts are supported; the value false means the opposite.|
**Example**
...
...
@@ -2756,7 +2756,7 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re
| Promise<boolean> | Promise used to return the result. If **true** is returned, multiple OS accounts are supported. If **false** is returned, multiple OS accounts are not supported.|
| Promise<boolean> | Promise used to return the result. The value **true** means multiple OS accounts are supported; the value false means the opposite.|
**Example**
...
...
@@ -2789,7 +2789,7 @@ Checks whether an OS account is activated. This API uses an asynchronous callbac
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, the account is activated. If **false** is returned, the account is not activated.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the account is activated; the value **false** means the opposite.|
**Example**: Check whether OS account 100 is activated.
...
...
@@ -2829,7 +2829,7 @@ Checks whether an OS account is activated. This API uses a promise to return the
| Promise<boolean> | Promise used to return the result. If **true** is returned, the account is activated. If **false** is returned, the account is not activated.|
| Promise<boolean> | Promise used to return the result. The value **true** means the account is activated; the value **false** means the opposite.|
**Example**: Check whether OS account 100 is activated.
...
...
@@ -2863,7 +2863,7 @@ Checks whether the specified constraint is enabled for an OS account. This API u
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, the constraint is enabled. If **false** is returned, the constraint is not enabled.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the specified constraint is enabled; the value **false** means the opposite.|
**Example**: Check whether OS account 100 is forbidden to use Wi-Fi.
...
...
@@ -2905,7 +2905,7 @@ Checks whether the specified constraint is enabled for an OS account. This API u
| Promise<boolean> | Promise used to return the result. If **true** is returned, the constraint is enabled. If **false** is returned, the constraint is not enabled.|
| Promise<boolean> | Promise used to return the result. The value **true** means the specified constraint is enabled; the value **false** means the opposite.|
**Example**: Check whether OS account 100 is forbidden to use Wi-Fi.
...
...
@@ -2936,7 +2936,7 @@ Checks whether this OS account is a test account. This API uses an asynchronous
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, the account is a test account. If **false** is returned, the account is not a test account.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the account is a test account; the value **false** means the opposite.|
**Example**
...
...
@@ -2967,7 +2967,7 @@ Checks whether this OS account is a test account. This API uses a promise to ret
| Promise<boolean> | Promise used to return the result. If **true** is returned, the account is a test account. If **false** is returned, the account is not a test account.|
| Promise<boolean> | Promise used to return the result. The value **true** means the account is a test account; the value **false** means the opposite.|
**Example**
...
...
@@ -2998,7 +2998,7 @@ Checks whether this OS account has been verified. This API uses an asynchronous
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, the account has been verified. If **false** is returned, the account has not been verified.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the OS account has been verified; the value **false** means the opposite.|
**Example**
...
...
@@ -3031,8 +3031,8 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca
| localId | number | No | ID of the target OS account. |
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If **true** is returned, the account has been verified. If **false** is returned, the account has not been verified.|
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the OS account has been verified; the value **false** means the opposite.|
**Example**
...
...
@@ -3072,7 +3072,7 @@ Checks whether an OS account has been verified. This API uses a promise to retur
| Promise<boolean> | Promise used to return the result. If **true** is returned, the account has been verified. If **false** is returned, the account has not been verified.|
| Promise<boolean> | Promise used to return the result. The value **true** means the OS account has been verified; the value **false** means the opposite.|
**Example**
...
...
@@ -3337,7 +3337,7 @@ Obtains the OS account ID based on the domain account information. This API uses
| request | [SetPropertyRequest](#setpropertyrequest8)| Yes | Request information, including the authentication credential type and the key value to set. |
| callback | AsyncCallback<number> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is a [result code](#resultcode8). Otherwise, **err** is an error object.|
| 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**
...
...
@@ -4018,9 +4018,12 @@ Sets the property for the initialization algorithm. This API uses an asynchronou
| callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the credential information obtained. Otherwise, **err** is an error object.|
| callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is information about all registered credentials of the user. Otherwise, **err** is an error object.|
**Error codes**
...
...
@@ -4974,7 +4977,7 @@ Called to return the result code and request result information.