提交 34a75dde 编写于 作者: A annie_wangli

update docs

Signed-off-by: Nannie_wangli <annie.wangli@huawei.com>
上级 4662fd8a
# App Account Management # App Account Management
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **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. > 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.
...@@ -12,23 +11,20 @@ import account_appAccount from '@ohos.account.appAccount'; ...@@ -12,23 +11,20 @@ import account_appAccount from '@ohos.account.appAccount';
``` ```
## System Capabilities
SystemCapability.Account.AppAccount
## account_appAccount.createAppAccountManager ## account_appAccount.createAppAccountManager
createAppAccountManager(): AppAccountManager; createAppAccountManager(): AppAccountManager
Creates an **AppAccountManager** instance. Creates an **AppAccountManager** instance.
- Return value **System capability**: SystemCapability.Account.AppAccount
| Type| Description|
| -------- | -------- |
| AppAccountManager | **AppAccountManager** instance created.|
- Example **Return Value**
| Type | Description |
| ----------------- | ------------------------ |
| AppAccountManager | **AppAccountManager** instance created.|
**Example**
``` ```
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
``` ```
...@@ -39,20 +35,20 @@ Provides methods to manage app accounts. ...@@ -39,20 +35,20 @@ Provides methods to manage app accounts.
### addAccount ### addAccount
addAccount(name: string, callback: AsyncCallback&lt;void&gt;): void; addAccount(name: string, callback: AsyncCallback&lt;void&gt;): void
Adds an app account to the account management service. This method uses an asynchronous callback to return the result. Adds an app account to the account management service. This method uses an asynchronous callback to return the result.
Required permission: none. **System capability**: SystemCapability.Account.AppAccount
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ | | -------- | ------------------------- | ---- | ------------------------------------------ |
| name | string | Yes| Name of the app account to add.| | name | string | Yes | Name of the app account to add. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked when the app account is added.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the app account is added.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -63,21 +59,21 @@ Required permission: none. ...@@ -63,21 +59,21 @@ Required permission: none.
### addAccount ### addAccount
addAccount(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;): void; addAccount(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;): void
Adds an app account and its additional information to the account management service. This method uses an asynchronous callback to return the result. Adds an app account and its additional information to the account management service. This method uses an asynchronous callback to return the result.
Required permission: none. **System capability**: SystemCapability.Account.AppAccount
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ | | --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| name | string | Yes| Name of the app account to add.| | name | string | Yes | Name of the app account to add. |
| extraInfo | string | Yes| Additional information (for example, token) of the app account to add. The additional information cannot contain sensitive information about the app account.| | extraInfo | string | Yes | Additional information (for example, token) of the app account to add. The additional information cannot contain sensitive information about the app account.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked when the app account and its additional information are added.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the app account and its additional information are added. |
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -90,26 +86,26 @@ Required permission: none. ...@@ -90,26 +86,26 @@ Required permission: none.
### addAccount ### addAccount
addAccount(name: string, extraInfo?: string): Promise&lt;void&gt;; addAccount(name: string, extraInfo?: string): Promise&lt;void&gt;
Adds an app account and its additional information to the account management service. This method uses a promise to return the result. Adds an app account and its additional information to the account management service. This method uses a promise to return the result.
Required permission: none. **System capability**: SystemCapability.Account.AppAccount
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ------------------------------------------------------------ | | --------- | ------ | ---- | ------------------------------------------------------------ |
| name | string | Yes| Name of the app account to add.| | name | string | Yes | Name of the app account to add. |
| extraInfo | string | Yes| Additional information of the app account to add. The additional information cannot contain sensitive information about the app account.| | extraInfo | string | Yes | Additional information of the app account to add. The additional information cannot contain sensitive information about the app account.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| ------------- | ---------------------------------- | | ------------------- | ---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -122,38 +118,38 @@ Required permission: none. ...@@ -122,38 +118,38 @@ Required permission: none.
### addAccountImplicitly<sup>8+</sup> ### addAccountImplicitly<sup>8+</sup>
addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
Implicitly adds an app account based on the specified account owner, authentication type, and options. This method uses an asynchronous callback to return the result. Implicitly adds an app account based on the specified account owner, authentication type, and options. This method uses an asynchronous callback to return the result.
Required permission: none. **System capability**: SystemCapability.Account.AppAccount
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | --------------------- | --- | -------------------------- | | -------- | --------------------- | ---- | ------------------------------ |
| owner | string | Yes| Bundle name of the app account to add.| | owner | string | Yes | Bundle name of the app account to add.|
| authType | string | Yes| Authentication type of the app account to add.| | authType | string | Yes | Authentication type of the app account to add. |
| options | {[key: string]: any} | Yes| Options for the authentication.| | options | {[key: string]: any} | Yes | Options for the authentication. |
| callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.| | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.|
- Example **Example**
``` ```
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) { function onResultCallback(code, result) {
console.log("resultCode: " + code); console.log("resultCode: " + code);
console.log("result: " + JSON.stringify(result)); console.log("result: " + JSON.stringify(result));
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
let abilityStartSetting = {want: request}; let abilityStartSetting = {want: request};
featureAbility.startAbility(abilityStartSetting, (err)=>{ featureAbility.startAbility(abilityStartSetting, (err)=>{
console.log("startAbility err: " + JSON.stringify(err)); console.log("startAbility err: " + JSON.stringify(err));
}); });
} }
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccountImplicitly("LiSi", "readAge", {}, { appAccountManager.addAccountImplicitly("LiSi", "readAge", {}, {
onResult: onResultCallback, onResult: onResultCallback,
...@@ -163,18 +159,20 @@ Required permission: none. ...@@ -163,18 +159,20 @@ Required permission: none.
### deleteAccount ### deleteAccount
deleteAccount(name: string, callback: AsyncCallback&lt;void&gt;): void; deleteAccount(name: string, callback: AsyncCallback&lt;void&gt;): void
Deletes an app account from the account management service. This method uses an asynchronous callback to return the result. Deletes an app account from the account management service. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------- | ------------------- | ---- | ---------------------------------- |
| name | string | Yes| Name of the app account to delete.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked when the app account is deleted.|
- Example | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------------------------------- |
| name | string | Yes | Name of the app account to delete. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the app account is deleted.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -185,23 +183,25 @@ Deletes an app account from the account management service. This method uses an ...@@ -185,23 +183,25 @@ Deletes an app account from the account management service. This method uses an
### deleteAccount ### deleteAccount
deleteAccount(name: string): Promise&lt;void&gt;; deleteAccount(name: string): Promise&lt;void&gt;
Deletes an app account from the account management service. This method uses a promise to return the result. Deletes an app account from the account management service. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------ | | ------ | ------ | ---- | ------------------------ |
| name | string | Yes| Name of the app account to delete.| | name | string | Yes | Name of the app account to delete.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| :------------ | :---------------------------------- | | :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -214,19 +214,21 @@ Deletes an app account from the account management service. This method uses a p ...@@ -214,19 +214,21 @@ Deletes an app account from the account management service. This method uses a p
### disableAppAccess ### disableAppAccess
disableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void; disableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void
Disables an app account from accessing an application with the given bundle name. This method uses an asynchronous callback to return the result. Disables an app account from accessing an application with the given bundle name. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| ---------- | ------------------- | ---- | ------------------------------------------------------------ |
| name | string | Yes| App account name.|
| bundleName | string | Yes| Bundle name of an app.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked when the app account is disabled from accessing the application with the given bundle name.|
- Example | Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ------------------------------------------------------------ |
| name | string | Yes | App account name. |
| bundleName | string | Yes | Bundle name of an app. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the app account is disabled from accessing the application with the given bundle name.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -237,24 +239,26 @@ Disables an app account from accessing an application with the given bundle name ...@@ -237,24 +239,26 @@ Disables an app account from accessing an application with the given bundle name
### disableAppAccess ### disableAppAccess
disableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;; disableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;
Disables an app account from accessing an application with the given bundle name. This method uses a promise to return the result. Disables an app account from accessing an application with the given bundle name. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ---------------------------------- | | ---------- | ------ | ---- | ---------------------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name.|
| bundleName | string | Yes| Bundle name of an app.| | bundleName | string | Yes | Bundle name of an app. |
- Return value **Return Value**
| Type| Description| | Type | Description |
| :------------ | :---------------------------------- | | :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -267,19 +271,21 @@ Disables an app account from accessing an application with the given bundle name ...@@ -267,19 +271,21 @@ Disables an app account from accessing an application with the given bundle name
### enableAppAccess ### enableAppAccess
enableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void; enableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void
Enables an app account to access an application with the given bundle name. This method uses an asynchronous callback to return the result. Enables an app account to access an application with the given bundle name. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ---------- | ------------------- | ---- | ------------------------------------------------------------ | | ---------- | ------------------------- | ---- | ------------------------------------------------------------ |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| bundleName | string | Yes| Bundle name of an app.| | bundleName | string | Yes | Bundle name of an app. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked when the app account is enabled to access the application with the given bundle name.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the app account is enabled to access the application with the given bundle name.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -290,24 +296,26 @@ Enables an app account to access an application with the given bundle name. This ...@@ -290,24 +296,26 @@ Enables an app account to access an application with the given bundle name. This
### enableAppAccess ### enableAppAccess
enableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;; enableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;
Enables an app account to access an application with the given bundle name. This method uses a promise to return the result. Enables an app account to access an application with the given bundle name. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| ---------- | ------ | ---- | ------------------ |
| name | string | Yes| App account name.|
| bundleName | string | Yes| Bundle name of an app.|
- Return value | Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------ |
| name | string | Yes | App account name. |
| bundleName | string | Yes | Bundle name of an app.|
| Type| Description| **Return Value**
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example | Type | Description |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
``` ```
app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
...@@ -319,20 +327,22 @@ Enables an app account to access an application with the given bundle name. This ...@@ -319,20 +327,22 @@ Enables an app account to access an application with the given bundle name. This
### checkAppAccountSyncEnable ### checkAppAccountSyncEnable
checkAppAccountSyncEnable(name: string, callback: AsyncCallback&lt;boolean&gt;): void; checkAppAccountSyncEnable(name: string, callback: AsyncCallback&lt;boolean&gt;): void
Checks whether an app account allows application data synchronization. This method uses an asynchronous callback to return the result. Checks whether an app account allows application data synchronization. This method uses an asynchronous callback to return the result.
The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only. **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
**System capability**: SystemCapability.Account.AppAccount
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------------------------------- | | -------- | ---------------------------- | ---- | -------------------------------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return whether the app account allows application data synchronization.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return whether the app account allows application data synchronization.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -344,25 +354,27 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis ...@@ -344,25 +354,27 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis
### checkAppAccountSyncEnable ### checkAppAccountSyncEnable
checkAppAccountSyncEnable(name: string): Promise&lt;boolean&gt;; checkAppAccountSyncEnable(name: string): Promise&lt;boolean&gt;
Checks whether an app account allows application data synchronization. This method uses a promise to return the result. Checks whether an app account allows application data synchronization. This method uses a promise to return the result.
The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only. **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| ------ | ------ | ---- | -------------- |
| name | string | Yes| App account name.|
- Return value | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------- |
| name | string | Yes | App account name.|
| Type| Description| **Return Value**
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
- Example | Type | Description |
| :--------------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -375,20 +387,22 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis ...@@ -375,20 +387,22 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis
### setAccountCredential ### setAccountCredential
setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback&lt;void&gt;): void; setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback&lt;void&gt;): void
Sets a credential for an app account. This method uses an asynchronous callback to return the result. Sets a credential for an app account. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------------- | ------------------- | ---- | ---------------------------- | | -------------- | ------------------------- | ---- | ---------------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| credentialType | string | Yes| Type of the credential to set.| | credentialType | string | Yes | Type of the credential to set. |
| credential | string | Yes| Credential to set.| | credential | string | Yes | Credential to set. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked when a credential is set for the specified app account.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when a credential is set for the specified app account.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -399,25 +413,27 @@ Sets a credential for an app account. This method uses an asynchronous callback ...@@ -399,25 +413,27 @@ Sets a credential for an app account. This method uses an asynchronous callback
### setAccountCredential ### setAccountCredential
setAccountCredential(name: string, credentialType: string, credential: string): Promise&lt;void&gt;; setAccountCredential(name: string, credentialType: string, credential: string): Promise&lt;void&gt;
Sets a credential for an app account. This method uses a promise to return the result asynchronously. Sets a credential for an app account. This method uses a promise to return the result asynchronously.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------------- | ------ | ---- | -------------------- |
| name | string | Yes| App account name.|
| credentialType | string | Yes| Type of the credential to set.|
| credential | string | Yes| Credential to set.|
- Return value | Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | -------------------- |
| name | string | Yes | App account name. |
| credentialType | string | Yes | Type of the credential to set.|
| credential | string | Yes | Credential to set. |
| Type| Description| **Return Value**
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example | Type | Description |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -430,19 +446,21 @@ Sets a credential for an app account. This method uses a promise to return the r ...@@ -430,19 +446,21 @@ Sets a credential for an app account. This method uses a promise to return the r
### setAccountExtraInfo ### setAccountExtraInfo
setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;): void; setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;): void
Sets additional information for an app account. This method uses an asynchronous callback to return the result. Sets additional information for an app account. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | -------------------------------- | | --------- | ------------------------- | ---- | -------------------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| extraInfo | string | Yes| Additional information to set.| | extraInfo | string | Yes | Additional information to set. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked when additional information is set for the specified app account.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when additional information is set for the specified app account.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -453,24 +471,26 @@ Sets additional information for an app account. This method uses an asynchronous ...@@ -453,24 +471,26 @@ Sets additional information for an app account. This method uses an asynchronous
### setAccountExtraInfo ### setAccountExtraInfo
setAccountExtraInfo(name: string, extraInfo: string): Promise&lt;void&gt;; setAccountExtraInfo(name: string, extraInfo: string): Promise&lt;void&gt;
Sets additional information for an app account. This method uses a promise to return the result asynchronously. Sets additional information for an app account. This method uses a promise to return the result asynchronously.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| --------- | ------ | ---- | ------------------ |
| name | string | Yes| App account name.|
| extraInfo | string | Yes| Additional information to set.|
- Return value | Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ------------------ |
| name | string | Yes | App account name. |
| extraInfo | string | Yes | Additional information to set.|
| Type| Description| **Return Value**
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example | Type | Description |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -483,21 +503,23 @@ Sets additional information for an app account. This method uses a promise to re ...@@ -483,21 +503,23 @@ Sets additional information for an app account. This method uses a promise to re
### setAppAccountSyncEnable ### setAppAccountSyncEnable
setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void; setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void
Sets whether to enable application data synchronization for an app account. This method uses an asynchronous callback to return the result. Sets whether to enable application data synchronization for an app account. This method uses an asynchronous callback to return the result.
The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only. **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
**System capability**: SystemCapability.Account.AppAccount
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | -------------------------------------------------- | | -------- | ------------------------- | ---- | -------------------------------------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| isEnable | boolean | Yes| Whether to enable app data synchronization.| | isEnable | boolean | Yes | Whether to enable app data synchronization. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked when application data synchronization is enabled or disabled for the app account.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when application data synchronization is enabled or disabled for the app account.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -508,26 +530,28 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis ...@@ -508,26 +530,28 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis
### setAppAccountSyncEnable ### setAppAccountSyncEnable
setAppAccountSyncEnable(name: string, isEnable: boolean): Promise&lt;void&gt;; setAppAccountSyncEnable(name: string, isEnable: boolean): Promise&lt;void&gt;
Sets whether to enable application data synchronization for an app account. This method uses a promise to return the result asynchronously. Sets whether to enable application data synchronization for an app account. This method uses a promise to return the result asynchronously.
The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only. **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
**System capability**: SystemCapability.Account.AppAccount
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------- | ---- | ---------------------- | | -------- | ------- | ---- | ---------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| isEnable | boolean | Yes| Whether to enable app data synchronization.| | isEnable | boolean | Yes | Whether to enable app data synchronization.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| :------------ | :---------------------------------- | | :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -540,20 +564,22 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis ...@@ -540,20 +564,22 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis
### setAssociatedData ### setAssociatedData
setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback&lt;void&gt;): void; setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback&lt;void&gt;): void
Sets data to be associated with an app account. This method uses an asynchronous callback to return the result. Sets data to be associated with an app account. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------- | ------------------- | ---- | ---------------------------------- |
| name | string | Yes| App account name.|
| key | string | Yes| Key of the data to set. The private key can be customized.|
| value | string | Yes| Value of the data to be set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked when the data associated with the specified app account is set.|
- Example | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------------------------------- |
| name | string | Yes | App account name. |
| key | string | Yes | Key of the data to set. The private key can be customized.|
| value | string | Yes | Value of the data to be set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the data associated with the specified app account is set.|
**Example**
``` ```
app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => { app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
...@@ -563,25 +589,27 @@ Sets data to be associated with an app account. This method uses an asynchronous ...@@ -563,25 +589,27 @@ Sets data to be associated with an app account. This method uses an asynchronous
### setAssociatedData ### setAssociatedData
setAssociatedData(name: string, key: string, value: string): Promise&lt;void&gt;; setAssociatedData(name: string, key: string, value: string): Promise&lt;void&gt;
Sets data to be associated with an app account. This method uses a promise to return the result asynchronously. Sets data to be associated with an app account. This method uses a promise to return the result asynchronously.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------- | | ------ | ------ | ---- | ---------------------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| key | string | Yes| Key of the data to set. The private key can be customized.| | key | string | Yes | Key of the data to set. The private key can be customized.|
| value | string | Yes| Value of the data to be set.| | value | string | Yes | Value of the data to be set. |
- Return value **Return Value**
| Type| Description| | Type | Description |
| :------------ | :---------------------------------- | | :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -594,19 +622,21 @@ Sets data to be associated with an app account. This method uses a promise to re ...@@ -594,19 +622,21 @@ Sets data to be associated with an app account. This method uses a promise to re
### getAccountCredential ### getAccountCredential
getAccountCredential(name: string, credentialType: string, callback: AsyncCallback&lt;string&gt;): void; getAccountCredential(name: string, credentialType: string, callback: AsyncCallback&lt;string&gt;): void
Obtains the credential of an app account. This method uses an asynchronous callback to return the result. Obtains the credential of an app account. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------------- | --------------------- | ---- | ---------------------------- |
| name | string | Yes| App account name.|
| credentialType | string | Yes| Type of the credential to obtain.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the credential of the specified app account.|
- Example | Name | Type | Mandatory| Description |
| -------------- | --------------------------- | ---- | ---------------------------- |
| name | string | Yes | App account name. |
| credentialType | string | Yes | Type of the credential to obtain. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the credential of the specified app account.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -618,24 +648,26 @@ Obtains the credential of an app account. This method uses an asynchronous callb ...@@ -618,24 +648,26 @@ Obtains the credential of an app account. This method uses an asynchronous callb
### getAccountCredential ### getAccountCredential
getAccountCredential(name: string, credentialType: string): Promise&lt;string&gt;; getAccountCredential(name: string, credentialType: string): Promise&lt;string&gt;
Obtains the credential of an app account. This method uses a promise to return the result asynchronously. Obtains the credential of an app account. This method uses a promise to return the result asynchronously.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | -------------------- | | -------------- | ------ | ---- | -------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| credentialType | string | Yes| Type of the credential to obtain.| | credentialType | string | Yes | Type of the credential to obtain.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| :-------------- | :---------------------------------- | | :-------------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -648,18 +680,20 @@ Obtains the credential of an app account. This method uses a promise to return t ...@@ -648,18 +680,20 @@ Obtains the credential of an app account. This method uses a promise to return t
### getAccountExtraInfo ### getAccountExtraInfo
getAccountExtraInfo(name: string, callback: AsyncCallback&lt;string&gt;): void; getAccountExtraInfo(name: string, callback: AsyncCallback&lt;string&gt;): void
Obtains additional information of an app account. This method uses an asynchronous callback to return the result. Obtains additional information of an app account. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------- | --------------------- | ---- | -------------------------------- |
| name | string | Yes| App account name.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the additional information of the specified app account.|
- Example | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------- |
| name | string | Yes | App account name. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the additional information of the specified app account.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -671,23 +705,25 @@ Obtains additional information of an app account. This method uses an asynchrono ...@@ -671,23 +705,25 @@ Obtains additional information of an app account. This method uses an asynchrono
### getAccountExtraInfo ### getAccountExtraInfo
getAccountExtraInfo(name: string): Promise&lt;string&gt;; getAccountExtraInfo(name: string): Promise&lt;string&gt;
Obtains additional information of an app account. This method uses a promise to return the result asynchronously. Obtains additional information of an app account. This method uses a promise to return the result asynchronously.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------- | | ------ | ------ | ---- | -------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| :-------------- | :---------------------------------- | | :-------------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -700,19 +736,21 @@ Obtains additional information of an app account. This method uses a promise to ...@@ -700,19 +736,21 @@ Obtains additional information of an app account. This method uses a promise to
### getAssociatedData ### getAssociatedData
getAssociatedData(name: string, key: string, callback: AsyncCallback&lt;string&gt;): void; getAssociatedData(name: string, key: string, callback: AsyncCallback&lt;string&gt;): void
Obtains data associated with an app account. This method uses an asynchronous callback to return the result. Obtains data associated with an app account. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------- | --------------------- | ---- | ---------------------------------- |
| name | string | Yes| App account name.|
| key | string | Yes| Key of the data to obtain.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the data associated with the specified app account.|
- Example | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------------- |
| name | string | Yes | App account name. |
| key | string | Yes | Key of the data to obtain. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the data associated with the specified app account.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -724,24 +762,26 @@ Obtains data associated with an app account. This method uses an asynchronous ca ...@@ -724,24 +762,26 @@ Obtains data associated with an app account. This method uses an asynchronous ca
### getAssociatedData ### getAssociatedData
getAssociatedData(name: string, key: string): Promise&lt;string&gt;; getAssociatedData(name: string, key: string): Promise&lt;string&gt;
Obtains data associated with an app account. This method uses a promise to return the result asynchronously. Obtains data associated with an app account. This method uses a promise to return the result asynchronously.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------- | | ------ | ------ | ---- | ------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| key | string | Yes| Key of the data to obtain.| | key | string | Yes | Key of the data to obtain.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| :-------------- | :---------------------------------- | | :-------------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -754,19 +794,21 @@ Obtains data associated with an app account. This method uses a promise to retur ...@@ -754,19 +794,21 @@ Obtains data associated with an app account. This method uses a promise to retur
### getAllAccessibleAccounts ### getAllAccessibleAccounts
getAllAccessibleAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void; getAllAccessibleAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void
Obtains information about all accessible app accounts. This method uses an asynchronous callback to return the result. Obtains information about all accessible app accounts. This method uses an asynchronous callback to return the result.
The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only. **Required permissions**: ohos.permission.GET_ACCOUNTS_PRIVILEGED (available only to system applications)
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------- | ------------------------------------ | ---- | ---------------- |
| callback | AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt; | Yes| Callback invoked to return information about all accessible app accounts.|
- Example | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ---------------- |
| callback | AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt; | Yes | Callback invoked to return information about all accessible app accounts.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -778,19 +820,21 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per ...@@ -778,19 +820,21 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per
### getAllAccessibleAccounts ### getAllAccessibleAccounts
getAllAccessibleAccounts(): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;; getAllAccessibleAccounts(): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;
Obtains information about all accessible app accounts. This method uses an asynchronous callback to return the result.
Obtains information about all accessible app accounts. This method uses a promise to return the result. **Required permissions**: ohos.permission.GET_ACCOUNTS_PRIVILEGED (available only to system applications)
The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only. **System capability**: SystemCapability.Account.AppAccount
- Parameters **Parameters**
| Type| Description| | Type | Description |
| ------------------------------ | ----------------------------------- | | ------------------------------------------ | ----------------------------------- |
| Promise&lt;Array&lt;AppAccountInfo&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;AppAccountInfo&gt;&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -803,20 +847,22 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per ...@@ -803,20 +847,22 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per
### getAllAccounts ### getAllAccounts
getAllAccounts(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void; getAllAccounts(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void
Obtains information about all app accounts of the specified app. This method uses an asynchronous callback to return the result. Obtains information about all app accounts of the specified app. This method uses an asynchronous callback to return the result.
The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only. **Required permissions**: ohos.permission.GET_ACCOUNTS_PRIVILEGED (available only to system applications)
**System capability**: SystemCapability.Account.AppAccount
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ---------------- | | -------- | ------------------------------------------------ | ---- | ---------------- |
| owner | string | Yes| Bundle name of the app.| | owner | string | Yes | Bundle name of the app. |
| callback | AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt; | Yes| Callback invoked to return information about all app accounts.| | callback | AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt; | Yes | Callback invoked to return information about all accessible app accounts.|
- Example **Example**
``` ```
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account.createAppAccountManager();
...@@ -829,25 +875,27 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per ...@@ -829,25 +875,27 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per
### getAllAccounts ### getAllAccounts
getAllAccounts(owner: string): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;; getAllAccounts(owner: string): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;
Obtains information about all app accounts of the specified app. This method uses an asynchronous callback to return the result.
Obtains information about all app accounts of the specified app. This method uses a promise to return the result. **Required permissions**: ohos.permission.GET_ACCOUNTS_PRIVILEGED (available only to system applications)
The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only. **System capability**: SystemCapability.Account.AppAccount
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------- | | ------ | ------ | ---- | ---------- |
| owner | string | Yes| Bundle name of the app.| | owner | string | Yes | Bundle name of the app.|
- Parameters **Parameters**
| Type| Description| | Type | Description |
| ------------------------------ | ----------------------------------- | | ------------------------------------------ | ----------------------------------- |
| Promise&lt;Array&lt;AppAccountInfo&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;AppAccountInfo&gt;&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -861,19 +909,21 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per ...@@ -861,19 +909,21 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per
### on('change') ### on('change')
on(type: 'change', owners: Array&lt;string&gt;, callback: Callback&lt;Array&lt;AppAccountInfo&gt;&gt;): void; on(type: 'change', owners: Array&lt;string&gt;, callback: Callback&lt;Array&lt;AppAccountInfo&gt;&gt;): void
Subscribes to the account change event of the specified account owners. This method uses an asynchronous callback to return the result. Subscribes to the account change event of the specified account owners. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | 'change' | Yes| Type of the event to subscribe to. The subscriber will receive a notification when the account owners update their accounts.|
| owners | Array&lt;string&gt; | Yes| Owners of the accounts.|
| callback | Callback&lt;Array&lt;AppAccountInfo&gt;&gt; | Yes| Callback invoked to return the account change.|
- Example | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | 'change' | Yes | Type of the event to subscribe to. The subscriber will receive a notification when the account owners update their accounts.|
| owners | Array&lt;string&gt; | Yes | Owners of the accounts. |
| callback | Callback&lt;Array&lt;AppAccountInfo&gt;&gt; | Yes | Callback invoked to return the account change. |
**Example**
``` ```
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account.createAppAccountManager();
...@@ -890,18 +940,20 @@ Subscribes to the account change event of the specified account owners. This met ...@@ -890,18 +940,20 @@ Subscribes to the account change event of the specified account owners. This met
### off('change') ### off('change')
off(type: 'change', callback?: Callback&lt;void&gt;): void; off(type: 'change', callback?: Callback<Array\<AppAccountInfo>>): void
Unsubscribes from the account change event. This method uses an asynchronous callback to return the result. Unsubscribes from the account change event. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ | | -------- | -------------------------------- | ---- | ------------------------ |
| type | 'change' | Yes| Account change event to unsubscribe from.| | type | 'change' | Yes | Account change event to unsubscribe from. |
| callback | Callback&lt;void&gt; | No| Callback used to report the account change.| | callback | Callback<Array\<AppAccountInfo>> | No | Callback used to report the account change.|
- Example **Example**
``` ```
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account.createAppAccountManager();
...@@ -921,37 +973,39 @@ Unsubscribes from the account change event. This method uses an asynchronous cal ...@@ -921,37 +973,39 @@ Unsubscribes from the account change event. This method uses an asynchronous cal
### authenticate<sup>8+</sup> ### authenticate<sup>8+</sup>
authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
Authenticates an app account to obtain the Open Authorization (OAuth) access token. This method uses an asynchronous callback to return the result. Authenticates an app account to obtain the Open Authorization (OAuth) access token. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | --------------------------- | | -------- | --------------------- | ---- | ------------------------------ |
| name | string | Yes| Name of the app account to authenticate.| | name | string | Yes | Name of the app account to authenticate. |
| owner | string | Yes| Bundle name of the app.| | owner | string | Yes | Bundle name of the app.|
| authType | string | Yes| Authentication type.| | authType | string | Yes | Authentication type. |
| options | {[key: string]: any} | Yes| Options for the authentication.| | options | {[key: string]: any} | Yes | Options for the authentication. |
| callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.| | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.|
- Example **Example**
``` ```
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) { function onResultCallback(code, result) {
console.log("resultCode: " + code); console.log("resultCode: " + code);
console.log("result: " + JSON.stringify(result)); console.log("result: " + JSON.stringify(result));
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
let abilityStartSetting = {want: request}; let abilityStartSetting = {want: request};
featureAbility.startAbility(abilityStartSetting, (err)=>{ featureAbility.startAbility(abilityStartSetting, (err)=>{
console.log("startAbility err: " + JSON.stringify(err)); console.log("startAbility err: " + JSON.stringify(err));
}); });
} }
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "readAge", {}, { appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "readAge", {}, {
onResult: onResultCallback, onResult: onResultCallback,
...@@ -961,20 +1015,22 @@ Authenticates an app account to obtain the Open Authorization (OAuth) access tok ...@@ -961,20 +1015,22 @@ Authenticates an app account to obtain the Open Authorization (OAuth) access tok
### getOAuthToken<sup>8+</sup> ### getOAuthToken<sup>8+</sup>
getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback&lt;string&gt;): void; getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback&lt;string&gt;): void
Obtains the OAuth access token of an app account based on the specified authentication type. This method uses an asynchronous callback to return the result. Obtains the OAuth access token of an app account based on the specified authentication type. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------- | | -------- | --------------------------- | ---- | ---------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| owner | string | Yes| Bundle name of the app.| | owner | string | Yes | Bundle name of the app.|
| authType | string | Yes| Authentication type.| | authType | string | Yes | Authentication type. |
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the result. |
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -986,25 +1042,27 @@ Obtains the OAuth access token of an app account based on the specified authenti ...@@ -986,25 +1042,27 @@ Obtains the OAuth access token of an app account based on the specified authenti
### getOAuthToken<sup>8+</sup> ### getOAuthToken<sup>8+</sup>
getOAuthToken(name: string, owner: string, authType: string): Promise&lt;string&gt;; getOAuthToken(name: string, owner: string, authType: string): Promise&lt;string&gt;
Obtains the OAuth access token of an app account based on the specified authentication type. This method uses a promise to return the result. Obtains the OAuth access token of an app account based on the specified authentication type. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------- | ------ | ---- | -------------------- |
| name | string | Yes| App account name.|
| owner | string | Yes| Bundle name of the app.|
| authType | string | Yes| Authentication type.|
- Parameters | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------------------- |
| name | string | Yes | App account name. |
| owner | string | Yes | Bundle name of the app.|
| authType | string | Yes | Authentication type. |
| Type| Description| **Parameters**
| --------------------- | -------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.|
- Example | Type | Description |
| --------------------- | ----------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1017,20 +1075,22 @@ Obtains the OAuth access token of an app account based on the specified authenti ...@@ -1017,20 +1075,22 @@ Obtains the OAuth access token of an app account based on the specified authenti
### setOAuthToken<sup>8+</sup> ### setOAuthToken<sup>8+</sup>
setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback&lt;void&gt;): void; setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback&lt;void&gt;): void
Sets an OAuth access token for an app account. This method uses an asynchronous callback to return the result. Sets an OAuth access token for an app account. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------- | | -------- | ------------------------- | ---- | ---------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name.|
| authType | string | Yes| Authentication type.| | authType | string | Yes | Authentication type. |
| token | string | Yes| OAuth access token to set.| | token | string | Yes | OAuth access token to set. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1041,25 +1101,27 @@ Sets an OAuth access token for an app account. This method uses an asynchronous ...@@ -1041,25 +1101,27 @@ Sets an OAuth access token for an app account. This method uses an asynchronous
### setOAuthToken<sup>8+</sup> ### setOAuthToken<sup>8+</sup>
setOAuthToken(name: string, authType: string, token: string): Promise&lt;void&gt;; setOAuthToken(name: string, authType: string, token: string): Promise&lt;void&gt;
Sets an OAuth access token for an app account. This method uses a promise to return the result. Sets an OAuth access token for an app account. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------- | ------ | ---- | ------------- |
| name | string | Yes| App account name.|
| authType | string | Yes| Authentication type.|
| token | string | Yes| OAuth access token to set.|
- Parameters | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------------- |
| name | string | Yes | App account name.|
| authType | string | Yes | Authentication type. |
| token | string | Yes | OAuth access token to set. |
| Type| Description| **Parameters**
| ------------------- | -------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example | Type | Description |
| ------------------- | ----------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1072,21 +1134,23 @@ Sets an OAuth access token for an app account. This method uses a promise to ret ...@@ -1072,21 +1134,23 @@ Sets an OAuth access token for an app account. This method uses a promise to ret
### deleteOAuthToken<sup>8+</sup> ### deleteOAuthToken<sup>8+</sup>
deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback&lt;void&gt;): void; deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback&lt;void&gt;): void
Deletes the specified OAuth access token for an app account. This method uses an asynchronous callback to return the result. Deletes the specified OAuth access token for an app account. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------ | | -------- | ------------------------- | ---- | ---------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| owner | string | Yes| Bundle name of the app.| | owner | string | Yes | Bundle name of the app.|
| authType | string | Yes| Authentication type.| | authType | string | Yes | Authentication type. |
| token | string | Yes| OAuth access token to delete.| | token | string | Yes | OAuth access token to delete. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1097,26 +1161,28 @@ Deletes the specified OAuth access token for an app account. This method uses an ...@@ -1097,26 +1161,28 @@ Deletes the specified OAuth access token for an app account. This method uses an
### deleteOAuthToken<sup>8+</sup> ### deleteOAuthToken<sup>8+</sup>
deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise&lt;void&gt;; deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise&lt;void&gt;
Deletes the specified OAuth access token for an app account. This method uses a promise to return the result. Deletes the specified OAuth access token for an app account. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------ | | -------- | ------ | ---- | ---------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| owner | string | Yes| Bundle name of the app.| | owner | string | Yes | Bundle name of the app.|
| authType | string | Yes| Authentication type.| | authType | string | Yes | Authentication type. |
| token | string | Yes| OAuth access token to delete.| | token | string | Yes | OAuth access token to delete. |
- Parameters **Parameters**
| Type| Description| | Type | Description |
| ------------------------------ | --------------------- | | ------------------- | ----------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1129,21 +1195,23 @@ Deletes the specified OAuth access token for an app account. This method uses a ...@@ -1129,21 +1195,23 @@ Deletes the specified OAuth access token for an app account. This method uses a
### setOAuthTokenVisibility<sup>8+</sup> ### setOAuthTokenVisibility<sup>8+</sup>
setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback&lt;void&gt;): void; setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback&lt;void&gt;): void
Sets the visibility of an OAuth access token to the specified app. This method uses an asynchronous callback to return the result. Sets the visibility of an OAuth access token to the specified app. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| ---------- | ------------------------- | ---- | ------------------- |
| name | string | Yes| App account name.|
| authType | string | Yes| Authentication type.|
| bundleName | string | Yes| Bundle name of the app.|
| isVisible | boolean | Yes| Whether the OAuth access token is visible to the app.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.|
- Example | Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ------------------------ |
| name | string | Yes | App account name. |
| authType | string | Yes | Authentication type. |
| bundleName | string | Yes | Bundle name of the app.|
| isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1154,26 +1222,28 @@ Sets the visibility of an OAuth access token to the specified app. This method u ...@@ -1154,26 +1222,28 @@ Sets the visibility of an OAuth access token to the specified app. This method u
### setOAuthTokenVisibility<sup>8+</sup> ### setOAuthTokenVisibility<sup>8+</sup>
setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise&lt;void&gt;; setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise&lt;void&gt;
Sets the visibility of an OAuth access token to the specified app. This method uses a promise to return the result. Sets the visibility of an OAuth access token to the specified app. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ------------------- | | ---------- | ------- | ---- | ------------------------ |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| authType | string | Yes| Authentication type.| | authType | string | Yes | Authentication type. |
| bundleName | string | Yes| Bundle name of the app.| | bundleName | string | Yes | Bundle name of the app.|
| isVisible | boolean | Yes| Whether the OAuth access token is visible to the app.| | isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. |
- Parameters **Parameters**
| Type| Description| | Type | Description |
| ------------------------------ | --------------------- | | ------------------- | ----------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1187,20 +1257,22 @@ Sets the visibility of an OAuth access token to the specified app. This method u ...@@ -1187,20 +1257,22 @@ Sets the visibility of an OAuth access token to the specified app. This method u
### checkOAuthTokenVisibility<sup>8+</sup> ### checkOAuthTokenVisibility<sup>8+</sup>
checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback&lt;boolean&gt;): void; checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback&lt;boolean&gt;): void
Checks whether an OAuth token is visible to the specified app. This method uses an asynchronous callback to return the result. Checks whether an OAuth token is visible to the specified app. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| ---------- | ---------------------------- | ---- | ---------------------- |
| name | string | Yes| App account name.|
| authType | string | Yes| Authentication type.|
| bundleName | string | Yes| Bundle name of the app.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback invoked to return the result.|
- Example | Name | Type | Mandatory| Description |
| ---------- | ---------------------------- | ---- | -------------------------- |
| name | string | Yes | App account name. |
| authType | string | Yes | Authentication type. |
| bundleName | string | Yes | Bundle name of the app.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. |
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1212,25 +1284,27 @@ Checks whether an OAuth token is visible to the specified app. This method uses ...@@ -1212,25 +1284,27 @@ Checks whether an OAuth token is visible to the specified app. This method uses
### checkOAuthTokenVisibility<sup>8+</sup> ### checkOAuthTokenVisibility<sup>8+</sup>
checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise&lt;boolean&gt;; checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise&lt;boolean&gt;
Checks whether an OAuth token is visible to the specified app. This method uses a promise to return the result. Checks whether an OAuth token is visible to the specified app. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ---------------------- | | ---------- | ------ | ---- | -------------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| authType | string | Yes| Authentication type.| | authType | string | Yes | Authentication type. |
| bundleName | string | Yes| Bundle name of the app.| | bundleName | string | Yes | Bundle name of the app.|
- Parameters **Parameters**
| Type| Description| | Type | Description |
| ------------------------------ | ------------------------ | | ---------------------- | ----------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1243,19 +1317,21 @@ Checks whether an OAuth token is visible to the specified app. This method uses ...@@ -1243,19 +1317,21 @@ Checks whether an OAuth token is visible to the specified app. This method uses
### getAllOAuthTokens<sup>8+</sup> ### getAllOAuthTokens<sup>8+</sup>
getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback&lt;Array&lt;OAuthTokenInfo&gt;&gt;): void; getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback&lt;Array&lt;OAuthTokenInfo&gt;&gt;): void
Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses an asynchronous callback to return the result. Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------- | ------------------------------------------------ | ---- | ------------------- |
| name | string | Yes| App account name.|
| owner | string | Yes| Bundle name of the app.|
| callback | AsyncCallback&lt;Array&lt;OAuthTokenInfo&gt;&gt; | Yes| Callback invoked to return the result.|
- Example | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ---------------------- |
| name | string | Yes | App account name. |
| owner | string | Yes | Bundle name of the app.|
| callback | AsyncCallback&lt;Array&lt;OAuthTokenInfo&gt;&gt; | Yes | Callback invoked to return the result. |
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1267,24 +1343,26 @@ Obtains information about all OAuth access tokens of an app account visible to t ...@@ -1267,24 +1343,26 @@ Obtains information about all OAuth access tokens of an app account visible to t
### getAllOAuthTokens<sup>8+</sup> ### getAllOAuthTokens<sup>8+</sup>
getAllOAuthTokens(name: string, owner: string): Promise&lt;Array&lt;OAuthTokenInfo&gt;&gt;; getAllOAuthTokens(name: string, owner: string): Promise&lt;Array&lt;OAuthTokenInfo&gt;&gt;
Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses a promise to return the result. Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------- | | ------ | ------ | ---- | ---------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| owner | string | Yes| Bundle name of the app.| | owner | string | Yes | Bundle name of the app.|
- Parameters **Parameters**
| Type| Description| | Type | Description |
| ------------------------------ | ----------------------------------- | | ------------------------------------------ | ----------------------------------- |
| Promise&lt;Array&lt;OAuthTokenInfo&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;OAuthTokenInfo&gt;&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1297,19 +1375,21 @@ Obtains information about all OAuth access tokens of an app account visible to t ...@@ -1297,19 +1375,21 @@ Obtains information about all OAuth access tokens of an app account visible to t
### getOAuthList<sup>8+</sup> ### getOAuthList<sup>8+</sup>
getOAuthList(name: string, authType: string, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void; getOAuthList(name: string, authType: string, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
Obtains the authorization list of OAuth access tokens of an app account. This method uses an asynchronous callback to return the result. Obtains the authorization list of OAuth access tokens of an app account. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| -------- | ---------------------------------------- | ---- | ------------------ |
| name | string | Yes| App account name.|
| owner | string | Yes| Bundle name of the app.|
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes| Callback invoked to return the result.|
- Example | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ---------------------- |
| name | string | Yes | App account name. |
| owner | string | Yes | Bundle name of the app.|
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the result. |
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1321,24 +1401,26 @@ Obtains the authorization list of OAuth access tokens of an app account. This me ...@@ -1321,24 +1401,26 @@ Obtains the authorization list of OAuth access tokens of an app account. This me
### getOAuthList<sup>8+</sup> ### getOAuthList<sup>8+</sup>
getOAuthList(name: string, authType: string): Promise&lt;Array&lt;string&gt;&gt;; getOAuthList(name: string, authType: string): Promise&lt;Array&lt;string&gt;&gt;
Obtains the authorization list of OAuth access tokens of an app account. This method uses a promise to return the result. Obtains the authorization list of OAuth access tokens of an app account. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------- | | ------ | ------ | ---- | ---------------------- |
| name | string | Yes| App account name.| | name | string | Yes | App account name. |
| owner | string | Yes| Bundle name of the app.| | owner | string | Yes | Bundle name of the app.|
- Parameters **Parameters**
| Type| Description| | Type | Description |
| ------------------------------ | ------------------------------------ | | ---------------------------------- | ----------------------------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1351,63 +1433,71 @@ Obtains the authorization list of OAuth access tokens of an app account. This me ...@@ -1351,63 +1433,71 @@ Obtains the authorization list of OAuth access tokens of an app account. This me
### getAuthenticatorCallback<sup>8+</sup> ### getAuthenticatorCallback<sup>8+</sup>
getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;AuthenticatorCallback&gt;): void; getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;AuthenticatorCallback&gt;): void
Obtains the authenticator callback for a session. This method uses an asynchronous callback to return the result. Obtains the authenticator callback for a session. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| --------- | ------------------------------------------ | ---- | -------------- | | --------- | ------------------------------------------ | ---- | ---------------- |
| sessionId | string | Yes| ID of the session to authenticate.| | sessionId | string | Yes | ID of the session to authenticate.|
| callback | AsyncCallback&lt;AuthenticatorCallback&gt; | Yes| Callback invoked to return the result.| | callback | AsyncCallback&lt;AuthenticatorCallback&gt; | Yes | Callback invoked to return the result.|
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant((err, want) => { featureAbility.getWant((err, want) => {
var sessionId = want.parameters[Constants.KEY_SESSION_ID]; var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => { appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => {
if (err.code != ResultCode.SUCCESS) { if (err.code != account_appAccount.ResultCode.SUCCESS) {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
return; return;
} }
var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
callback.OnResult(ResultCode.SUCCESS, result); [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
}); });
}); });
``` ```
### getAuthenticatorCallback<sup>8+</sup> ### getAuthenticatorCallback<sup>8+</sup>
getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt;; getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt;
Obtains the authenticator callback for a session. This method uses a promise to return the result. Obtains the authenticator callback for a session. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| ---------- | ------ | ---- | -------------- |
| sessionId | string | Yes| ID of the session to authenticate.|
- Parameters | Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ---------------- |
| sessionId | string | Yes | ID of the session to authenticate.|
| Type| Description| **Parameters**
| ------------------------------------ | -------------------------------- |
| Promise&lt;AuthenticatorCallback&gt; | Promise used to return the result.|
- Example | Type | Description |
| ------------------------------------ | ----------------------------------- |
| Promise&lt;AuthenticatorCallback&gt; | Promise used to return the result.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant().then((want) => { featureAbility.getWant().then((want) => {
var sessionId = want.parameters[Constants.KEY_SESSION_ID]; var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
callback.OnResult(ResultCode.SUCCESS, result); [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
}); });
...@@ -1418,18 +1508,20 @@ Obtains the authenticator callback for a session. This method uses a promise to ...@@ -1418,18 +1508,20 @@ Obtains the authenticator callback for a session. This method uses a promise to
### getAuthenticatorInfo<sup>8+</sup> ### getAuthenticatorInfo<sup>8+</sup>
getAuthenticatorInfo(owner: string, callback: AsyncCallback&lt;AuthenticatorInfo&gt;): void; getAuthenticatorInfo(owner: string, callback: AsyncCallback&lt;AuthenticatorInfo&gt;): void
Obtains authenticator information of an app account. This method uses an asynchronous callback to return the result. Obtains authenticator information of an app account. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------- | | -------- | -------------------------------------- | ---- | ---------------------- |
| owner | string | Yes| Bundle name of the app.| | owner | string | Yes | Bundle name of the app.|
| callback | AsyncCallback&lt;AuthenticatorInfo&gt; | Yes| Callback invoked to return the result.| | callback | AsyncCallback&lt;AuthenticatorInfo&gt; | Yes | Callback invoked to return the result. |
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1441,23 +1533,25 @@ Obtains authenticator information of an app account. This method uses an asynchr ...@@ -1441,23 +1533,25 @@ Obtains authenticator information of an app account. This method uses an asynchr
### getAuthenticatorInfo<sup>8+</sup> ### getAuthenticatorInfo<sup>8+</sup>
getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;; getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;
Obtains authenticator information of an app account. This method uses a promise to return the result. Obtains authenticator information of an app account. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description| **Parameters**
| ----- | ------ | ---- | -------------------- |
| owner | string | Yes| Bundle name of the app.|
- Parameters | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------- |
| owner | string | Yes | Bundle name of the app.|
| Type| Description| **Parameters**
| ------------------------------ | ----------------------------------- |
| Promise&lt;AuthenticatorInfo&gt; | Promise used to return the result.|
- Example | Type | Description |
| -------------------------------- | ----------------------------------- |
| Promise&lt;AuthenticatorInfo&gt; | Promise used to return the result.|
**Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
...@@ -1472,73 +1566,83 @@ Obtains authenticator information of an app account. This method uses a promise ...@@ -1472,73 +1566,83 @@ Obtains authenticator information of an app account. This method uses a promise
Defines app account information. Defines app account information.
| Name| Type| Mandatory| Description| **System capability**: SystemCapability.Account.AppAccount
| ----- | ------ | ---- | ---------------- |
| owner | string | Yes| Bundle name of the app.| | Name| Type | Mandatory| Description |
| name | string | Yes| App account name.| | ------ | ------ | ---- | ---------------------- |
| owner | string | Yes | Bundle name of the app.|
| name | string | Yes | App account name. |
## OAuthTokenInfo<sup>8+</sup> ## OAuthTokenInfo<sup>8+</sup>
Defines OAuth access token information. Defines OAuth access token information.
| Name| Type| Mandatory| Description| **System capability**: SystemCapability.Account.AppAccount
| -------- | ------ | ---- | -------------- |
| authType | string | Yes| Authentication type.| | Name | Type | Mandatory| Description |
| token | string | Yes| Value of the access token.| | -------- | ------ | ---- | ---------------- |
| authType | string | Yes | Authentication type.|
| token | string | Yes | Value of the access token. |
## AuthenticatorInfo<sup>8+</sup> ## AuthenticatorInfo<sup>8+</sup>
Defines OAuth authenticator information. Defines OAuth authenticator information.
| Name| Type| Mandatory| Description| **System capability**: SystemCapability.Account.AppAccount
| ------- | ------ | ---- | ------------------ |
| owner | string | Yes| Bundle name of the authenticator owner.| | Name | Type | Mandatory| Description |
| iconId | string | Yes| ID of the authenticator icon.| | ------- | ------ | ---- | -------------------- |
| labelId | string | Yes| ID of the authenticator label.| | owner | string | Yes | Bundle name of the authenticator owner.|
| iconId | string | Yes | ID of the authenticator icon. |
| labelId | string | Yes | ID of the authenticator label. |
## Constants<sup>8+</sup> ## Constants<sup>8+</sup>
Enumerates the constants. Enumerates the constants.
| Name| Default Value| Description| **System capability**: SystemCapability.Account.AppAccount
| ----------------------------- | ---------------------- | ----------------------- |
| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation for implicitly adding an account.| | Name | Default Value | Description |
| ACTION_AUTHENTICATE | "authenticate" | Authentication operation.| | ----------------------------- | ---------------------- | ------------------------- |
| KEY_NAME | "name" | App account name.| | ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation for implicitly adding an account. |
| ACTION_AUTHENTICATE | "authenticate" | Authentication operation. |
| KEY_NAME | "name" | App account name. |
| KEY_OWNER | "owner" | App account owner.| | KEY_OWNER | "owner" | App account owner.|
| KEY_TOKEN | "token" | OAuth access token.| | KEY_TOKEN | "token" | OAuth access token. |
| KEY_ACTION | "action" | Action.| | KEY_ACTION | "action" | Action. |
| KEY_AUTH_TYPE | "authType" | Authentication type.| | KEY_AUTH_TYPE | "authType" | Authentication type. |
| KEY_SESSION_ID | "sessionId" | Session ID.| | KEY_SESSION_ID | "sessionId" | Session ID. |
| KEY_CALLER_PID | "callerPid" | Caller process ID (PID).| | KEY_CALLER_PID | "callerPid" | Caller process ID (PID). |
| KEY_CALLER_UID | "callerUid" | Caller user ID (UID).| | KEY_CALLER_UID | "callerUid" | Caller user ID (UID). |
| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Caller bundle name.| | KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Caller bundle name. |
## ResultCode<sup>8+</sup> ## ResultCode<sup>8+</sup>
Enumerates the result codes. Enumerates the result codes.
| Name| Default Value| Description| **System capability**: SystemCapability.Account.AppAccount
| ----------------------------------- | ----- | ---------------------- |
| SUCCESS | 0 | The operation is successful.| | Name | Default Value| Description |
| ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist.| | ----------------------------------- | ------ | ------------------------ |
| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | The app account service is abnormal.| | SUCCESS | 0 | The operation is successful. |
| ERROR_INVALID_PASSWORD | 10003 | The password is invalid.| | ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist. |
| ERROR_INVALID_REQUEST | 10004 | The request is invalid.| | ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | The app account service is abnormal. |
| ERROR_INVALID_RESPONSE | 10005 | The response is invalid.| | ERROR_INVALID_PASSWORD | 10003 | The password is invalid. |
| ERROR_NETWORK_EXCEPTION | 10006 | The network is abnormal.| | ERROR_INVALID_REQUEST | 10004 | The request is invalid. |
| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | The authenticator does not exist.| | ERROR_INVALID_RESPONSE | 10005 | The response is invalid. |
| ERROR_OAUTH_CANCELED | 10008 | The authentication is canceled.| | ERROR_NETWORK_EXCEPTION | 10006 | The network is abnormal. |
| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | The size of the OAuth list exceeds the limit.| | ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | The authenticator does not exist. |
| ERROR_OAUTH_SERVICE_BUSY | 10010 | The OAuth service is busy.| | ERROR_OAUTH_CANCELED | 10008 | The authentication is canceled. |
| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal.| | ERROR_OAUTH_LIST_TOO_LARGE | 10009 | The size of the OAuth list exceeds the limit. |
| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist.| | ERROR_OAUTH_SERVICE_BUSY | 10010 | The OAuth service is busy. |
| ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out.| | ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal. |
| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth access token does not exist.| | ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist. |
| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth access tokens reaches the limit.| | ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out. |
| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported.| | ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth access token does not exist.|
| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported.| | ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth access tokens reaches the limit. |
| ERROR_PERMISSION_DENIED | 10018 | The required permission is missing.| | ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported. |
| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported. |
| ERROR_PERMISSION_DENIED | 10018 | The required permission is missing. |
## AuthenticatorCallback<sup>8+</sup> ## AuthenticatorCallback<sup>8+</sup>
...@@ -1546,25 +1650,29 @@ Provides methods for managing the OAuth authenticator callback. ...@@ -1546,25 +1650,29 @@ Provides methods for managing the OAuth authenticator callback.
### onResult<sup>8+</sup> ### onResult<sup>8+</sup>
onResult: (code: number, result: {[key: string]: any}) =&gt; void; onResult: (code: number, result: {[key: string]: any}) =&gt; void
Called back to send the authentication result. Called back to send the authentication result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description|
| ------ | -------------------- | ---- | ----------- | **Parameters**
| code | number | Yes| Authentication result code.| | Name| Type | Mandatory| Description |
| result | {[key: string]: any} | Yes| Authentication result.| | ------ | -------------------- | ---- | ------------ |
| code | number | Yes | Authentication result code.|
| result | {[key: string]: any} | Yes | Authentication result. |
- Example **Example**
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234"; var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
callback.OnResult(ResultCode.SUCCESS, result); [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
}); });
...@@ -1572,16 +1680,18 @@ Called back to send the authentication result. ...@@ -1572,16 +1680,18 @@ Called back to send the authentication result.
### onRequestRedirected<sup>8+</sup> ### onRequestRedirected<sup>8+</sup>
onRequestRedirected: (request: Want) =&gt; void; onRequestRedirected: (request: Want) =&gt; void
Called back to redirect an authentication request. Called back to redirect an authentication request.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description|
| ------- | ---- | ---- | ------------------ |
| request | Want | Yes| Request to be redirected.|
- Example **Parameters**
| Name | Type| Mandatory| Description |
| ------- | ---- | ---- | -------------------- |
| request | Want | Yes | Request to be redirected.|
**Example**
``` ```
class MyAuthenticator extends account_appAccount.Authenticator { class MyAuthenticator extends account_appAccount.Authenticator {
...@@ -1591,10 +1701,12 @@ Called back to redirect an authentication request. ...@@ -1591,10 +1701,12 @@ Called back to redirect an authentication request.
abilityName: "com.example.ohos.accountjsdemo.LoginAbility", abilityName: "com.example.ohos.accountjsdemo.LoginAbility",
}); });
} }
authenticate(name, authType, callerBundleName, options, callback) { authenticate(name, authType, callerBundleName, options, callback) {
var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"}; var result = {[account_appAccount.Constants.KEY_NAME]: name,
callback.onResult(ResultCode.SUCCESS, result); [account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
} }
} }
``` ```
...@@ -1605,34 +1717,38 @@ Defines the OAuth authenticator base class. ...@@ -1605,34 +1717,38 @@ Defines the OAuth authenticator base class.
### addAccountImplicitly<sup>8+</sup> ### addAccountImplicitly<sup>8+</sup>
addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
Implicitly adds an app account based on the specified authentication type and options. This method uses an asynchronous callback to return the result. Implicitly adds an app account based on the specified authentication type and options. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description|
| ---------------- | --------------------- | --- | -------------------------- | **Parameters**
| authType | string | Yes| Authentication type.| | Name | Type | Mandatory| Description |
| callerBundleName | string | Yes| Bundle name of the authentication requester.| | ---------------- | --------------------- | ---- | ------------------------------ |
| options | {[key: string]: any} | Yes| Options for the authentication.| | authType | string | Yes | Authentication type. |
| callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.| | callerBundleName | string | Yes | Bundle name of the authentication requester. |
| options | {[key: string]: any} | Yes | Options for the authentication. |
| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.|
### authenticate<sup>8+</sup> ### authenticate<sup>8+</sup>
authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
Authenticates an app account to obtain the OAuth access token. This method uses an asynchronous callback to return the result. Authenticates an app account to obtain the OAuth access token. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.AppAccount
| Name| Type| Mandatory| Description|
| ---------------- | --------------------- | ---- | -------------------------- | **Parameters**
| name | string | Yes| App account name.| | Name | Type | Mandatory| Description |
| authType | string | Yes| Authentication type.| | ---------------- | --------------------- | ---- | ------------------------------ |
| callerBundleName | string | Yes| Bundle name of the authentication requester.| | name | string | Yes | App account name. |
| options | {[key: string]: any} | Yes| Options for the authentication.| | authType | string | Yes | Authentication type. |
| callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.| | callerBundleName | string | Yes | Bundle name of the authentication requester. |
| options | {[key: string]: any} | Yes | Options for the authentication. |
| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.|
- Example **Example**
``` ```
class MyAuthenticator extends account_appAccount.Authenticator { class MyAuthenticator extends account_appAccount.Authenticator {
...@@ -1642,13 +1758,15 @@ Authenticates an app account to obtain the OAuth access token. This method uses ...@@ -1642,13 +1758,15 @@ Authenticates an app account to obtain the OAuth access token. This method uses
abilityName: "com.example.ohos.accountjsdemo.LoginAbility", abilityName: "com.example.ohos.accountjsdemo.LoginAbility",
}); });
} }
authenticate(name, authType, callerBundleName, options, callback) { authenticate(name, authType, callerBundleName, options, callback) {
var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"}; var result = {[account_appAccount.Constants.KEY_NAME]: name,
callback.onResult(ResultCode.SUCCESS, result); [account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
} }
} }
export default { export default {
onConnect(want) { onConnect(want) {
return new MyAuthenticator(); return new MyAuthenticator();
......
...@@ -10,33 +10,34 @@ ...@@ -10,33 +10,34 @@
import account_osAccount from '@ohos.account.osAccount'; import account_osAccount from '@ohos.account.osAccount';
``` ```
## System Capabilities
SystemCapability.Account.OsAccount
## account_osAccount.getAccountManager ## account_osAccount.getAccountManager
getAccountManager(): AccountManager getAccountManager(): AccountManager
Obtains an **AccountManager** instance. Obtains an **AccountManager** instance.
- Return value **System capability**: SystemCapability.Account.OsAccount
| Type| Description|
| -------- | -------- |
| [AccountManager](#accountmanager) | **AccountManager** instance obtained.|
- Example **Return Value**
| Type | Description |
| --------------------------------- | ------------------------ |
| [AccountManager](#accountmanager) | Obtains an **AccountManager** instance.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
``` ```
## OsAccountType ## OsAccountType
Enumerates OS account types. Enumerates OS account types.
| Name| Default Value| Description|
| -------- | -------- | -------- | **System capability**: SystemCapability.Account.OsAccount
| ADMIN | 0 | Administrator account|
| NORMAL | 1 | Normal account| | Name | Default Value| Description |
| GUEST | 2 | Guest account| | ------ | ------ | ------------ |
| ADMIN | 0 | Administrator account|
| NORMAL | 1 | Normal account |
| GUEST | 2 | Guest account |
## AccountManager ## AccountManager
...@@ -48,17 +49,18 @@ activateOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -48,17 +49,18 @@ activateOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
Activates an OS account. This method uses an asynchronous callback to return the result. Activates an OS account. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| -------- | ------------------- | ---- | -------------------- |
| localId | number | Yes | ID of the OS account to activate.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
- Example | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------- |
Activate OS account 100. | localId | number | Yes | ID of the OS account to activate.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**: Activate OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -73,22 +75,23 @@ activateOsAccount(localId: number): Promise&lt;void&gt; ...@@ -73,22 +75,23 @@ activateOsAccount(localId: number): Promise&lt;void&gt;
Activates an OS account. This method uses a promise to return the result. Activates an OS account. This method uses a promise to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the OS account to activate.|
- Return value | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | -------------------- |
| localId | number | Yes | ID of the OS account to activate.|
| Type | Description | **Return Value**
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example | Type | Description |
| :------------------ | :---------------------------------- |
Activate OS account 100. | Promise&lt;void&gt; | Promise used to return the result.|
**Example**: Activate OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -105,13 +108,15 @@ isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -105,13 +108,15 @@ isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether multiple OS accounts are supported. This method uses an asynchronous callback to return the result. Checks whether multiple OS accounts are supported. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------ | | -------- | ---------------------------- | ---- | --------------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -127,13 +132,15 @@ isMultiOsAccountEnable(): Promise&lt;boolean&gt; ...@@ -127,13 +132,15 @@ isMultiOsAccountEnable(): Promise&lt;boolean&gt;
Checks whether multiple OS accounts are supported. This method uses a promise to return the result. Checks whether multiple OS accounts are supported. This method uses a promise to return the result.
- Return value **System capability**: SystemCapability.Account.OsAccount
| Type | Description | **Return Value**
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.|
- Example | Type | Description |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -150,17 +157,19 @@ isOsAccountActived(localId: number, callback: AsyncCallback&lt;boolean&gt;): voi ...@@ -150,17 +157,19 @@ isOsAccountActived(localId: number, callback: AsyncCallback&lt;boolean&gt;): voi
Checks whether an OS account is activated. This method uses an asynchronous callback to return the result. Checks whether an OS account is activated. This method uses an asynchronous callback to return the result.
- Parameters **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| -------- | ---------------------- | ---- | ------------------------------ |
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.|
- Example | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ------------------------------------------------- |
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.|
**Example**: Check whether OS account 100 is activated.
Check whether OS account 100 is activated.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var osLocalId = 100; var osLocalId = 100;
...@@ -176,22 +185,24 @@ isOsAccountActived(localId: number): Promise&lt;boolean&gt; ...@@ -176,22 +185,24 @@ isOsAccountActived(localId: number): Promise&lt;boolean&gt;
Checks whether an OS account is activated. This method uses a promise to return the result. Checks whether an OS account is activated. This method uses a promise to return the result.
- Parameters **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
- Return value | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
| Type | Description | **Return Value**
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.|
- Example | Type | Description |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.|
**Example**: Check whether OS account 100 is activated.
Check whether OS account 100 is activated.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var osLocalId = 100; var osLocalId = 100;
...@@ -208,18 +219,20 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async ...@@ -208,18 +219,20 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async
Checks whether the specified constraint is enabled for an OS account. This method uses an asynchronous callback to return the result. Checks whether the specified constraint is enabled for an OS account. This method uses an asynchronous callback to return the result.
- Parameters **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| ---------- | ---------------------- | ---- | ------------------------------ |
| localId | number | Yes | ID of the target OS account.|
| [constraint](#constraints) | string | Yes | Constraint specified.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.|
- Example | Name | Type | Mandatory| Description |
| ---------- | ---------------------------- | ---- | ------------------------------------------------- |
| localId | number | Yes | ID of the target OS account. |
| constraint | string | Yes | [Constraint](#constraints) specified. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.|
** Example**: Check whether OS account 100 is forbidden to use Wi-Fi.
Check whether OS account 100 is forbidden to use Wi-Fi.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -235,23 +248,25 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise&lt;boo ...@@ -235,23 +248,25 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise&lt;boo
Checks whether the specified constraint is enabled for an OS account. This method uses a promise to return the result. Checks whether the specified constraint is enabled for an OS account. This method uses a promise to return the result.
- Parameters **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| ---------- | ------ | ---- | ---------------- |
| localId | number | Yes | ID of the target OS account.|
| [constraint](#constraints)| string | Yes | Constraint specified.|
- Return value | Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------------------- |
| localId | number | Yes | ID of the target OS account. |
| constraint | string | Yes | [Constraint](#constraints) specified.|
| Type | Description | **Return Value**
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.|
- Example | Type | Description |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.|
** Example**: Check whether OS account 100 is forbidden to use Wi-Fi.
Check whether OS account 100 is forbidden to use Wi-Fi.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -268,13 +283,15 @@ isTestOsAccount(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -268,13 +283,15 @@ isTestOsAccount(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether this OS account is a test account. This method uses an asynchronous callback to return the result. Checks whether this OS account is a test account. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------ | | -------- | ---------------------------- | ---- | ----------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -290,13 +307,15 @@ isTestOsAccount(): Promise&lt;boolean&gt; ...@@ -290,13 +307,15 @@ isTestOsAccount(): Promise&lt;boolean&gt;
Checks whether this OS account is a test account. This method uses a promise to return the result. Checks whether this OS account is a test account. This method uses a promise to return the result.
- Return value **System capability**: SystemCapability.Account.OsAccount
| Type | Description | **Return Value**
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.|
- Example | Type | Description |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -313,13 +332,15 @@ isOsAccountVerified(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -313,13 +332,15 @@ isOsAccountVerified(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether this OS account has been verified. This method uses an asynchronous callback to return the result. Checks whether this OS account has been verified. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ---------------------------------- | | -------- | ---------------------------- | ---- | ------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -335,14 +356,16 @@ isOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): vo ...@@ -335,14 +356,16 @@ isOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): vo
Checks whether an OS account has been verified. This method uses an asynchronous callback to return the result. Checks whether an OS account has been verified. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| -------- | ---------------------- | ---- | ---------------------------------- |
| localId | number | No | ID of the target OS account. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.|
- Example | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ------------------------------------------- |
| localId | number | No | ID of the target OS account. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -354,23 +377,25 @@ Checks whether an OS account has been verified. This method uses an asynchronous ...@@ -354,23 +377,25 @@ Checks whether an OS account has been verified. This method uses an asynchronous
### isOsAccountVerified ### isOsAccountVerified
isOsAccountVerified(localId: number?): Promise&lt;boolean&gt; isOsAccountVerified(localId?: number): Promise&lt;boolean&gt;
Checks whether an OS account has been verified. This method uses a promise to return the result. Checks whether an OS account has been verified. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ | | ------- | ------ | ---- | ------------------ |
| localId | number | No | ID of the target OS account.| | localId | number | No | ID of the target OS account.|
- Return value **Return Value**
| Type | Description | | Type | Description |
| :--------------- | :---------------------------------- | | :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.| | Promise&lt;boolean&gt; | Promise used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -387,21 +412,27 @@ removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -387,21 +412,27 @@ removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
Removes an OS account. This method uses an asynchronous callback to return the result. Removes an OS account. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
| -------- | ------------------- | ---- | ------------------------ |
| localId | number | Yes | ID of the OS account to remove. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
- Example **System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------- |
| localId | number | Yes | ID of the OS account to remove.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var createIocalId; var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
createIocalId = osAccountInfo.localId; createIocalId = osAccountInfo.localId;
)}; });
accountManager.removeOsAccount(createIocalId, (err)=>{ accountManager.removeOsAccount(createIocalId, (err)=>{
console.log("removeOsAccount err:" + JSON.stringify(err)); console.log("removeOsAccount err:" + JSON.stringify(err));
}); });
...@@ -413,26 +444,32 @@ removeOsAccount(localId: number): Promise&lt;void&gt; ...@@ -413,26 +444,32 @@ removeOsAccount(localId: number): Promise&lt;void&gt;
Removes an OS account. This method uses a promise to return the result. Removes an OS account. This method uses a promise to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ | | ------- | ------ | ---- | -------------------- |
| localId | number | Yes | ID of the OS account to remove.| | localId | number | Yes | ID of the OS account to remove.|
- Return value **Return Value**
| Type | Description | | Type | Description |
| :------------ | :---------------------------------- | | :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var createIocalId; var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
createIocalId = osAccountInfo.localId; createIocalId = osAccountInfo.localId;
)}; });
createIocalId = osAccount.localId; createIocalId = osAccount.localId;
accountManager.removeOsAccount(createIocalId).then(() => { accountManager.removeOsAccount(createIocalId).then(() => {
console.log('removeOsAccount Success'); console.log('removeOsAccount Success');
...@@ -445,21 +482,25 @@ Removes an OS account. This method uses a promise to return the result. ...@@ -445,21 +482,25 @@ Removes an OS account. This method uses a promise to return the result.
setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean,callback: AsyncCallback&lt;void&gt;): void setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean,callback: AsyncCallback&lt;void&gt;): void
Sets or removes constraints for an OS account. This method uses an asynchronous callback to return the result. Sets or removes constraints for an OS account.
This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------------------- | ---- | ------------------------------- | | ----------- | ------------------------- | ---- | -------------------------------------------- |
| localId | number | Yes | ID of the target OS account. | | localId | number | Yes | ID of the target OS account. |
| [constraints](constraints)| Array&lt;string&gt; | Yes | List of constraints to set or remove. | | constraints | Array&lt;string&gt; | Yes | List of [constraints](#constraints) to set or remove.|
| enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints. | | enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
- Example ** Example**: Disable Wi-Fi for OS account 100.
Disable Wi-Fi for OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -472,26 +513,30 @@ Sets or removes constraints for an OS account. This method uses an asynchronous ...@@ -472,26 +513,30 @@ Sets or removes constraints for an OS account. This method uses an asynchronous
setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean): Promise&lt;void&gt; setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean): Promise&lt;void&gt;
Sets or removes constraints for an OS account. This method uses a promise to return the result. Sets or removes constraints for an OS account.
- Parameters This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
| ----------- | ------------- | ---- | ----------------------- |
| localId | number | Yes | ID of the target OS account. |
| [constraints](constraints)| Array&lt;string&gt; | Yes | List of constraints to set or remove.|
| enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints.|
- Return value **System capability**: SystemCapability.Account.OsAccount
| Type | Description | **Parameters**
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example | Name | Type | Mandatory| Description |
| ----------- | ------------------- | ---- | -------------------------------------------- |
| localId | number | Yes | ID of the target OS account. |
| constraints | Array&lt;string&gt; | Yes | List of [constraints](#constraints) to set or remove.|
| enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints. |
**Return Value**
| Type | Description |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**: Remote the constraint on the use of Wi-Fi for OS account 100.
Remove the constraint on Wi-Fi for OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -508,18 +553,20 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback&lt; ...@@ -508,18 +553,20 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback&lt;
Sets a name for an OS account. This method uses an asynchronous callback to return the result. Sets a name for an OS account. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| :-------- | ------------------- | ---- | ------------------------ |
| localId | number | Yes | ID of the target OS account. |
| localName | string | Yes | Account name to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
- Example | Name | Type | Mandatory| Description |
| :-------- | ------------------------- | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
| localName | string | Yes | Account name to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**: Set the name of OS account 100 to **demoName**.
Set the name of OS account 100 to **demoName**.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -535,23 +582,25 @@ setOsAccountName(localId: number, localName: string): Promise&lt;void&gt; ...@@ -535,23 +582,25 @@ setOsAccountName(localId: number, localName: string): Promise&lt;void&gt;
Sets a name for an OS account. This method uses a promise to return the result. Sets a name for an OS account. This method uses a promise to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| --------- | ------ | ---- | ----------------------- |
| localId | number | Yes | ID of the target OS account. |
| localName | string | Yes | Account name to set.|
- Return value | Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
| localName | string | Yes | Account name to set. |
| Type | Description | **Return Value**
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example | Type | Description |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**: Set the name of OS account 100 to **demoName**.
Set the name of OS account 100 to **demoName**.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -569,13 +618,17 @@ getCreatedOsAccountsCount(callback: AsyncCallback&lt;number&gt;): void ...@@ -569,13 +618,17 @@ getCreatedOsAccountsCount(callback: AsyncCallback&lt;number&gt;): void
Obtains the number of OS accounts created. This method uses an asynchronous callback to return the result. Obtains the number of OS accounts created. This method uses an asynchronous callback to return the result.
- Parameters **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| -------- | --------------------- | ---- | ------------------------------ |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the number of OS accounts created.|
- Example | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------ |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the number of OS accounts created.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -591,13 +644,17 @@ getCreatedOsAccountsCount(): Promise&lt;number&gt; ...@@ -591,13 +644,17 @@ getCreatedOsAccountsCount(): Promise&lt;number&gt;
Obtains the number of OS accounts created. This method uses a promise to return the result. Obtains the number of OS accounts created. This method uses a promise to return the result.
- Return value **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
**Return Value**
| Type | Description | | Type | Description |
| :-------------- | :---------------------------------- | | :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the number of OS accounts created.| | Promise&lt;number&gt; | Promise used to return the number of OS accounts created.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -614,13 +671,15 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback&lt;number&gt;): void ...@@ -614,13 +671,15 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback&lt;number&gt;): void
Obtains the ID of the OS account to which the current process belongs. This method uses an asynchronous callback to return the result. Obtains the ID of the OS account to which the current process belongs. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| -------- | --------------------- | ---- | ----------------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the account ID obtained.|
- Example | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the account ID obtained.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -636,13 +695,15 @@ getOsAccountLocalIdFromProcess(): Promise&lt;number&gt; ...@@ -636,13 +695,15 @@ getOsAccountLocalIdFromProcess(): Promise&lt;number&gt;
Obtains the ID of the OS account to which the current process belongs. This method uses a promise to return the result. Obtains the ID of the OS account to which the current process belongs. This method uses a promise to return the result.
- Return value **System capability**: SystemCapability.Account.OsAccount
**Return Value**
| Type | Description | | Type | Description |
| :-------------- | :---------------------------------- | | :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the account ID obtained.| | Promise&lt;number&gt; | Promise used to return the account ID obtained.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -659,17 +720,17 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback&lt;number&gt;): ...@@ -659,17 +720,17 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback&lt;number&gt;):
Obtains the OS account ID based on the process UID. This method uses an asynchronous callback to return the result. Obtains the OS account ID based on the process UID. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| -------- | --------------------- | ---- | --------------------------------------- |
| uid | number | Yes | Process UID.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the OS account ID obtained.|
- Example | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | --------------------------------------------- |
| uid | number | Yes | Process UID. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the OS account ID obtained.|
**Example**: Obtain the ID of the OS account whose process UID is **12345678**.
Obtain the ID of the OS account whose process UID is **12345678**.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
let uid = 12345678; let uid = 12345678;
...@@ -685,22 +746,22 @@ getOsAccountLocalIdFromUid(uid: number): Promise&lt;number&gt; ...@@ -685,22 +746,22 @@ getOsAccountLocalIdFromUid(uid: number): Promise&lt;number&gt;
Obtains the OS account ID based on the process UID. This method uses a promise to return the result. Obtains the OS account ID based on the process UID. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------- | | ------ | ------ | ---- | --------- |
| uid | number | Yes | Process UID.| | uid | number | Yes | Process UID.|
- Return value **Return Value**
| Type | Description | | Type | Description |
| :-------------- | :---------------------------------- | | :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the OS account ID obtained.| | Promise&lt;number&gt; | Promise used to return the OS account ID obtained.|
- Example **Example**: Obtain the ID of the OS account whose process UID is **12345678**.
Obtain the ID of the OS account whose process UID is **12345678**.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
let uid = 12345678; let uid = 12345678;
...@@ -711,20 +772,24 @@ Obtains the OS account ID based on the process UID. This method uses a promise t ...@@ -711,20 +772,24 @@ Obtains the OS account ID based on the process UID. This method uses a promise t
}); });
``` ```
### getOsAccountLocalIdFromDomain ### getOsAccountLocalIdFromDomain<sup>8+</sup>
getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;number&gt;): void getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;number&gt;): void
Obtains the OS account ID based on domain account information. This method uses an asynchronous callback to return the result. Obtains the OS account ID based on domain account information. This method uses an asynchronous callback to return the result.
- Parameters **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
| Name | Type | Mandatory| Description | **System capability**: SystemCapability.Account.OsAccount
| -------- | --------------------- | ---- | --------------------------------------- |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the ID of the OS account associated with the domain account.|
- Example **Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | -------------------------------------------- |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the ID of the OS account associated with the domain account.|
**Example**
``` ```
var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
...@@ -735,25 +800,29 @@ Obtains the OS account ID based on domain account information. This method uses ...@@ -735,25 +800,29 @@ Obtains the OS account ID based on domain account information. This method uses
}); });
``` ```
### getOsAccountLocalIdFromDomain ### getOsAccountLocalIdFromDomain<sup>8+</sup>
getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise&lt;number&gt; getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise&lt;number&gt;
Obtains the OS account ID based on domain account information. This method uses a promise to return the result. Obtains the OS account ID based on domain account information. This method uses a promise to return the result.
- Parameters **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ------------- | | ---------- | --------------------------------------- | ---- | ------------ |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information.| | domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information.|
- Return value **Return Value**
| Type | Description | | Type | Description |
| :-------------- | :---------------------------------- | | :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the ID of the OS account associated with the domain account.| | Promise&lt;number&gt; | Promise used to return the ID of the OS account associated with the domain account.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -771,13 +840,17 @@ queryMaxOsAccountNumber(callback: AsyncCallback&lt;number&gt;): void ...@@ -771,13 +840,17 @@ queryMaxOsAccountNumber(callback: AsyncCallback&lt;number&gt;): void
Obtains the maximum number of OS accounts that can be created. This method uses an asynchronous callback to return the result. Obtains the maximum number of OS accounts that can be created. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | **System capability**: SystemCapability.Account.OsAccount
| -------- | --------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the maximum number of OS accounts that can be created.|
- Example **Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------------ |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the maximum number of OS accounts that can be created.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -793,13 +866,17 @@ queryMaxOsAccountNumber(): Promise&lt;number&gt; ...@@ -793,13 +866,17 @@ queryMaxOsAccountNumber(): Promise&lt;number&gt;
Obtains the maximum number of OS accounts that can be created. This method uses a promise to return the result. Obtains the maximum number of OS accounts that can be created. This method uses a promise to return the result.
- Return value This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
**Return Value**
| Type | Description | | Type | Description |
| :-------------- | :---------------------------------- | | :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the maximum number of OS accounts that can be created.| | Promise&lt;number&gt; | Promise used to return the maximum number of OS accounts that can be created.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -814,19 +891,21 @@ Obtains the maximum number of OS accounts that can be created. This method uses ...@@ -814,19 +891,21 @@ Obtains the maximum number of OS accounts that can be created. This method uses
getOsAccountAllConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void getOsAccountAllConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
Obtains all constraints of an OS account. This method uses an asynchronous callback to return the result. Obtains all constraints enabled for an OS account. This method uses an asynchronous callback to return the result.
- Parameters **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
| Name | Type | Mandatory| Description | **System capability**: SystemCapability.Account.OsAccount
| -------- | ---------------------------- | ---- | ---------------------------------- |
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback used to return all constraints obtained.|
- Example **Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ |
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback used to return all [constraints](#constraints) obtained.|
** Example**: Obtain all constraints of OS account 100.
Obtain all constraints of OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -840,24 +919,26 @@ Obtains all constraints of an OS account. This method uses an asynchronous callb ...@@ -840,24 +919,26 @@ Obtains all constraints of an OS account. This method uses an asynchronous callb
getOsAccountAllConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt; getOsAccountAllConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
Obtains all constraints of an OS account. This method uses a promise to return the result. Obtains all constraints enabled for an OS account. This method uses a promise to return the result.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
- Parameters **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
- Return value | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
| Type | Description | **Return Value**
| :--------------------- | :---------------------------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the constraints obtained.|
- Example | Type | Description |
| :--------------------------------- | :----------------------------------------------------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the [constraints](#constraints) obtained.|
** Example**: Obtain all constraints of OS account 100.
Obtain all constraints of OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -874,13 +955,17 @@ queryAllCreatedOsAccounts(callback: AsyncCallback&lt;Array&lt;OsAccountInfo&gt;& ...@@ -874,13 +955,17 @@ queryAllCreatedOsAccounts(callback: AsyncCallback&lt;Array&lt;OsAccountInfo&gt;&
Obtains information about all the OS accounts created. This method uses an asynchronous callback to return the result. Obtains information about all the OS accounts created. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| -------- | ----------------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | Yes | Callback used to return information about OS accounts created.|
- Example | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | Yes | Callback used to return information about OS accounts created.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -896,13 +981,17 @@ queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt; ...@@ -896,13 +981,17 @@ queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt;
Obtains information about all the OS accounts created. This method uses a promise to return the result. Obtains information about all the OS accounts created. This method uses a promise to return the result.
- Return value This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| Type | Description | **Return Value**
| :---------------------------- | :---------------------------------- |
| Promise&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | Promise used to return information about OS accounts created.|
- Example | Type | Description |
| :---------------------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | Promise used to return information about OS accounts created.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -913,19 +1002,21 @@ Obtains information about all the OS accounts created. This method uses a promis ...@@ -913,19 +1002,21 @@ Obtains information about all the OS accounts created. This method uses a promis
}); });
``` ```
### queryActivatedOsAccountIds ### queryActivatedOsAccountIds<sup>8+</sup>
queryActivatedOsAccountIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void queryActivatedOsAccountIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
Obtains information about all activated OS accounts. This method uses an asynchronous callback to return the result. Obtains information about all activated OS accounts. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | -------------------------------- | | -------- | ---------------------------------------- | ---- | ------------------------------------------------------ |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return information about activated OS accounts.| | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return information about activated OS accounts.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -938,19 +1029,21 @@ Obtains information about all activated OS accounts. This method uses an asynchr ...@@ -938,19 +1029,21 @@ Obtains information about all activated OS accounts. This method uses an asynchr
}); });
``` ```
### queryActivatedOsAccountIds ### queryActivatedOsAccountIds<sup>8+</sup>
queryActivatedOsAccountIds(): Promise&lt;Array&lt;number&gt;&gt; queryActivatedOsAccountIds(): Promise&lt;Array&lt;number&gt;&gt;
Obtains information about all activated OS accounts. This method uses a promise to return the result. Obtains information about all activated OS accounts. This method uses a promise to return the result.
- Return value **System capability**: SystemCapability.Account.OsAccount
| Type | Description | **Return Value**
| :---------------------------- | :---------------------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return information about activated OS accounts.|
- Example | Type | Description |
| :--------------------------------- | :----------------------------------------------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return information about activated OS accounts.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -967,15 +1060,21 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback& ...@@ -967,15 +1060,21 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&
Creates an OS account. This method uses an asynchronous callback to return the result. Creates an OS account. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
| Name | Type | Mandatory| Description | **System capability**: SystemCapability.Account.OsAccount
| :-------- | ---------------------------- | ---- | -------------------- |
| localName | string | Yes | Name of the OS account to create. |
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create. |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return the OS account created.|
- Example **Parameters**
| Name | Type | Mandatory| Description |
| :-------- | ---------------------------------------------------- | ---- | ------------------------------------------ |
| localName | string | Yes | Name of the OS account to create. |
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create. |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return the OS account created.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -991,20 +1090,26 @@ createOsAccount(localName: string, type: OsAccountType): Promise&lt;OsAccountInf ...@@ -991,20 +1090,26 @@ createOsAccount(localName: string, type: OsAccountType): Promise&lt;OsAccountInf
Creates an OS account. This method uses a promise to return the result. Creates an OS account. This method uses a promise to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| --------- | ------------- | ---- | ---------------- |
| localName | string | Yes | Name of the OS account to create.|
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.|
- Return value | Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ---------------------- |
| localName | string | Yes | Name of the OS account to create.|
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.|
| Type | Description | **Return Value**
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account created.|
- Example | Type | Description |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account created.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -1015,21 +1120,27 @@ Creates an OS account. This method uses a promise to return the result. ...@@ -1015,21 +1120,27 @@ Creates an OS account. This method uses a promise to return the result.
}); });
``` ```
### createOsAccountForDomain ### createOsAccountForDomain<sup>8+</sup>
createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;OsAccountInfo&gt;): void createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;OsAccountInfo&gt;): void
Creates an OS account and associates it with the specified domain account. This method uses an asynchronous callback to return the result. Creates an OS account and associates it with the specified domain account. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| :-------- | ---------------------------- | ---- | -------------------- |
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create. |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return the OS account created.|
- Example | Name | Type | Mandatory| Description |
| :--------- | ---------------------------------------------------- | ---- | ------------------------------------------ |
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create. |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return the OS account created.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -1040,26 +1151,32 @@ Creates an OS account and associates it with the specified domain account. This ...@@ -1040,26 +1151,32 @@ Creates an OS account and associates it with the specified domain account. This
}); });
``` ```
### createOsAccountForDomain ### createOsAccountForDomain<sup>8+</sup>
createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise&lt;OsAccountInfo&gt; createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise&lt;OsAccountInfo&gt;
Creates an OS account and associates it with the specified domain account. This method uses a promise to return the result. Creates an OS account and associates it with the specified domain account. This method uses a promise to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------------- | ---- | ---------------- | | ---------- | --------------------------------------- | ---- | ---------------------- |
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.| | type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.|
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information.| | domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. |
- Return value **Return Value**
| Type | Description | | Type | Description |
| :--------------------- | :---------------------------------- | | :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account created.| | Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account created.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -1077,13 +1194,17 @@ queryCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void ...@@ -1077,13 +1194,17 @@ queryCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void
Obtains information about the OS account to which the current process belongs. This method uses an asynchronous callback to return the result. Obtains information about the OS account to which the current process belongs. This method uses an asynchronous callback to return the result.
- Parameters **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
| Name | Type | Mandatory| Description | **System capability**: SystemCapability.Account.OsAccount
| -------- | ---------------------------- | ---- | -------------------------- |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return information about the OS account obtained.|
- Example **Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return information about the OS account obtained.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -1099,13 +1220,17 @@ queryCurrentOsAccount(): Promise&lt;OsAccountInfo&gt; ...@@ -1099,13 +1220,17 @@ queryCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;
Obtains information about the OS account to which the current process belongs. This method uses a promise to return the result. Obtains information about the OS account to which the current process belongs. This method uses a promise to return the result.
- Return value **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
**Return Value**
| Type | Description | | Type | Description |
| :--------------------- | :---------------------------------- | | :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return information about the OS account obtained.| | Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return information about the OS account obtained.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -1122,17 +1247,21 @@ queryOsAccountById(localId: number, callback: AsyncCallback&lt;OsAccountInfo&gt; ...@@ -1122,17 +1247,21 @@ queryOsAccountById(localId: number, callback: AsyncCallback&lt;OsAccountInfo&gt;
Obtains information about an OS account. This method uses an asynchronous callback to return the result. Obtains information about an OS account. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
| -------- | ---------------------------- | ---- | -------------------------- |
| localId | number | Yes | ID of the target OS account.|
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return the OS account information obtained.|
- Example **System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------- | ---- | ---------------------------------------- |
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return the OS account information obtained.|
**Example**: Query information about OS account 100.
Query information about OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -1148,22 +1277,26 @@ queryOsAccountById(localId: number): Promise&lt;OsAccountInfo&gt; ...@@ -1148,22 +1277,26 @@ queryOsAccountById(localId: number): Promise&lt;OsAccountInfo&gt;
Obtains information about an OS account. This method uses a promise to return the result. Obtains information about an OS account. This method uses a promise to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
| Name | Type | Mandatory| Description | **System capability**: SystemCapability.Account.OsAccount
| -------- | ---------------------------- | ---- | -------------------------- |
| localId | number | Yes | ID of the target OS account.|
- Return value **Parameters**
| Type | Description | | Name | Type | Mandatory| Description |
| :--------------------- | :---------------------------------- | | ------- | ------ | ---- | -------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account information obtained.| | localId | number | Yes | ID of the target OS account.|
- Example **Return Value**
| Type | Description |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account information obtained.|
**Example**: Query information about OS account 100.
Query information about OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -1180,13 +1313,15 @@ getOsAccountTypeFromProcess(callback: AsyncCallback&lt;OsAccountType&gt;): void ...@@ -1180,13 +1313,15 @@ getOsAccountTypeFromProcess(callback: AsyncCallback&lt;OsAccountType&gt;): void
Obtains the type of the OS account to which the current process belongs. This method uses an asynchronous callback to return the result. Obtains the type of the OS account to which the current process belongs. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- |
| callback | AsyncCallback&lt;[OsAccountType](#osaccounttype)&gt; | Yes | Callback used to return the OS account type.| | callback | AsyncCallback&lt;[OsAccountType](#osaccounttype)&gt; | Yes | Callback used to return the OS account type.|
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -1202,13 +1337,15 @@ getOsAccountTypeFromProcess(): Promise&lt;OsAccountType&gt; ...@@ -1202,13 +1337,15 @@ getOsAccountTypeFromProcess(): Promise&lt;OsAccountType&gt;
Obtains the type of the OS account to which the current process belongs. This method uses a promise to return the result. Obtains the type of the OS account to which the current process belongs. This method uses a promise to return the result.
- Return value **System capability**: SystemCapability.Account.OsAccount
| Type | Description | **Return Value**
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountType](#osaccounttype)&gt; | Promise used to return the OS account type.|
- Example | Type | Description |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountType](#osaccounttype)&gt; | Promise used to return the OS account type.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -1225,13 +1362,17 @@ getDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void ...@@ -1225,13 +1362,17 @@ getDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void
Obtains the ID of this distributed virtual device. This method uses an asynchronous callback to return the result. Obtains the ID of this distributed virtual device. This method uses an asynchronous callback to return the result.
- Parameters **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| -------- | --------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the device ID obtained.|
- Example | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the device ID obtained.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -1247,13 +1388,17 @@ getDistributedVirtualDeviceId(): Promise&lt;string&gt; ...@@ -1247,13 +1388,17 @@ getDistributedVirtualDeviceId(): Promise&lt;string&gt;
Obtains the ID of this distributed virtual device. This method uses a promise to return the result. Obtains the ID of this distributed virtual device. This method uses a promise to return the result.
- Return value **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.Account.OsAccount
| Type | Description | **Return Value**
| :-------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise used to return the device ID obtained.|
- Example | Type | Description |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the device ID obtained.|
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -1270,17 +1415,21 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;) ...@@ -1270,17 +1415,21 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;)
Obtains the profile photo of an OS account. This method uses an asynchronous callback to return the result. Obtains the profile photo of an OS account. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------ | | -------- | --------------------------- | ---- | ---------------------------------------- |
| localId | number | Yes | ID of the target OS account. | | localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the profile photo obtained.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the profile photo obtained.|
- Example **Example**: Obtain the profile photo of OS account 100.
Obtain the profile photo of OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -1296,22 +1445,26 @@ getOsAccountProfilePhoto(localId: number): Promise&lt;string&gt; ...@@ -1296,22 +1445,26 @@ getOsAccountProfilePhoto(localId: number): Promise&lt;string&gt;
Obtains the profile photo of an OS account. This method uses a promise to return the result. Obtains the profile photo of an OS account. This method uses a promise to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
- Return value **System capability**: SystemCapability.Account.OsAccount
| Type | Description | **Parameters**
| :-------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise used to return the profile photo obtained.|
- Example | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
**Return Value**
| Type | Description |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the profile photo obtained.|
**Example**: Obtain the profile photo of OS account 100.
Obtain the profile photo of OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -1328,18 +1481,22 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback ...@@ -1328,18 +1481,22 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback
Sets a profile photo for an OS account. This method uses an asynchronous callback to return the result. Sets a profile photo for an OS account. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
| Name | Type | Mandatory| Description | **System capability**: SystemCapability.Account.OsAccount
| -------- | ------------------- | ---- | ------------------------ |
| localId | number | Yes | ID of the target OS account. |
| photo | string | Yes | Profile photo information. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
- Example **Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
| photo | string | Yes | Profile photo information. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**: Set a profile photo for OS account 100.
Set a profile photo for OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -1358,23 +1515,27 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt; ...@@ -1358,23 +1515,27 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt;
Sets a profile photo for an OS account. This method uses a promise to return the result. Sets a profile photo for an OS account. This method uses a promise to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
| Name | Type | Mandatory| Description | **System capability**: SystemCapability.Account.OsAccount
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
| photo | string | Yes | Profile photo information. |
- Return value **Parameters**
| Type | Description | | Name | Type | Mandatory| Description |
| :------------ | :---------------------------------- | | ------- | ------ | ---- | ------------ |
| Promise&lt;void&gt; | Promise used to return the result.| | localId | number | Yes | ID of the target OS account.|
| photo | string | Yes | Profile photo information. |
- Example **Return Value**
| Type | Description |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**: Set a profile photo for OS account 100.
Set a profile photo for OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -1389,23 +1550,23 @@ Sets a profile photo for an OS account. This method uses a promise to return the ...@@ -1389,23 +1550,23 @@ Sets a profile photo for an OS account. This method uses a promise to return the
}); });
``` ```
### getOsAccountLocalIdBySerialNumber ### getOsAccountLocalIdBySerialNumber<sup>8+</sup>
getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&lt;number&gt;): void getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&lt;number&gt;): void
Obtains the OS account ID based on the SN. This method uses an asynchronous callback to return the result. Obtains the OS account ID based on the SN. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| ------------ | --------------------- | ---- | ------------------------------ |
| serialNumber | number | Yes | Account SN. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the OS account ID obtained.|
- Example | Name | Type | Mandatory| Description |
| ------------ | --------------------------- | ---- | ------------------------------------------------ |
| serialNumber | number | Yes | Account SN. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the OS account ID obtained.|
**Example**: Obtain the ID of the OS account whose SN is **12345**.
Obtain the ID of the OS account whose SN is 12345.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var serialNumber = 12345; var serialNumber = 12345;
...@@ -1415,28 +1576,28 @@ Obtains the OS account ID based on the SN. This method uses an asynchronous call ...@@ -1415,28 +1576,28 @@ Obtains the OS account ID based on the SN. This method uses an asynchronous call
}); });
``` ```
### getOsAccountLocalIdBySerialNumber ### getOsAccountLocalIdBySerialNumber<sup>8+</sup>
getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt; getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt;
Obtains the OS account ID based on the SN. This method uses a promise to return the result. Obtains the OS account ID based on the SN. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | ------ | ---- | ---------- | | ------------ | ------ | ---- | ---------- |
| serialNumber | number | Yes | Account SN.| | serialNumber | number | Yes | Account SN.|
- Return value **Return Value**
| Type | Description | | Type | Description |
| :-------------- | :---------------------------------- | | :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the OS account ID obtained.| | Promise&lt;number&gt; | Promise used to return the OS account ID obtained.|
- Example **Example**: Obtain the ID of the OS account whose SN is **12345**.
Obtain the ID of the OS account whose SN is 12345.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var serialNumber = 12345; var serialNumber = 12345;
...@@ -1447,23 +1608,23 @@ Obtains the OS account ID based on the SN. This method uses a promise to return ...@@ -1447,23 +1608,23 @@ Obtains the OS account ID based on the SN. This method uses a promise to return
}); });
``` ```
### getSerialNumberByOsAccountLocalId ### getSerialNumberByOsAccountLocalId<sup>8+</sup>
getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback&lt;number&gt;): void getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback&lt;number&gt;): void
Obtains the SN of an OS account based on the account ID. This method uses an asynchronous callback to return the result. Obtains the SN of an OS account based on the account ID. This method uses an asynchronous callback to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| -------- | --------------------- | ---- | ------------------------------ |
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the account SN obtained.|
- Example | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------ |
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the account SN obtained.|
**Example**: Obtain the SN of OS account 100.
Obtain the SN of the OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -1473,28 +1634,28 @@ Obtains the SN of an OS account based on the account ID. This method uses an asy ...@@ -1473,28 +1634,28 @@ Obtains the SN of an OS account based on the account ID. This method uses an asy
}); });
``` ```
### getSerialNumberByOsAccountLocalId ### getSerialNumberByOsAccountLocalId<sup>8+</sup>
getSerialNumberByOsAccountLocalId(localId: number): Promise&lt;number&gt; getSerialNumberByOsAccountLocalId(localId: number): Promise&lt;number&gt;
Obtains the SN of an OS account based on the account ID. This method uses a promise to return the result. Obtains the SN of an OS account based on the account ID. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ | | ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.| | localId | number | Yes | ID of the target OS account.|
- Return value **Return Value**
| Type | Description | | Type | Description |
| :-------------- | :---------------------------------- | | :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the account SN obtained.| | Promise&lt;number&gt; | Promise used to return the account SN obtained.|
- Example **Example**: Obtain the SN of OS account 100.
Obtain the SN of the OS account 100.
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
...@@ -1511,15 +1672,21 @@ on(type: 'activate' | 'activating', name: string, callback: Callback&lt;number&g ...@@ -1511,15 +1672,21 @@ on(type: 'activate' | 'activating', name: string, callback: Callback&lt;number&g
Subscribes to OS account changes. This method uses an asynchronous callback to return the result. Subscribes to OS account changes. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description | **Parameters**
| -------- | -------------------------- | ---- | ------------------------ |
| 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. |
| name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes.|
| callback | Callback&lt;number&gt; | Yes | Callback used to return the OS account ID and status changes.|
- Example | Name | Type | Mandatory| Description |
| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
| 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.|
| name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes. |
| callback | Callback&lt;number&gt; | Yes | Callback used to return the OS account ID and status changes. |
**Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -1535,15 +1702,21 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number ...@@ -1535,15 +1702,21 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number
Unsubscribes from the OS account changes. This method uses an asynchronous callback to return the result. Unsubscribes from the OS account changes. This method uses an asynchronous callback to return the result.
- Parameters This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
**System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------- | ---- | ---------------------------- | | -------- | -------------------------- | ---- | ------------------------------------------------------------ |
| 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. | | 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()**.| | 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&lt;number&gt; | No | Callback used to return the OS account changes. By default, **0** is returned.| | callback | Callback&lt;number&gt; | No | Callback used to return the OS account changes. By default, **0** is returned. |
- Example **Example**
``` ```
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
...@@ -1555,44 +1728,50 @@ Unsubscribes from the OS account changes. This method uses an asynchronous callb ...@@ -1555,44 +1728,50 @@ Unsubscribes from the OS account changes. This method uses an asynchronous callb
## OsAccountInfo ## OsAccountInfo
Defines information about an OS account. Defines information about an OS account.
| Name | Type | Mandatory| Description |
| ----------------- | ---------------------------------- | ---- | ------------------------ | **System capability**: SystemCapability.Account.OsAccount
| localId | number | Yes | ID of the target OS account. |
| localName | string | Yes | OS account name. | | Name | Type | Mandatory| Description |
| type | [OsAccountType](#osaccounttype) | Yes | OS account type. | | ----------------- | ------------------------------------------------------------ | ---- | --------------------------------- |
| [constraints](constraints) | Array&lt;string&gt; | No | Constraints on the OS account. | | localId | number | Yes | ID of the target OS account. |
| isVerified | boolean | Yes | Whether the OS account is verified. | | localName | string | Yes | OS account name. |
| photo | string | No | Profile photo of the OS account. | | type | [OsAccountType](#osaccounttype) | Yes | OS account type. |
| createTime | number | Yes | Time when the OS account was created. | | constraints | Array&lt;string&gt; | No | [Constraints](#constraints) on the OS account.|
| lastLoginTime | number | No | Last login time of the OS account.| | isVerified | boolean | Yes | Whether the OS account is verified. |
| serialNumber | number | Yes | SN of the OS account. | | photo | string | No | Profile photo of the OS account. |
| isActived | boolean | Yes | Whether the OS account is activated. | | createTime | number | Yes | Time when the OS account was created. |
| isCreateCompleted | boolean | Yes | Whether the OS account information is complete. | | lastLoginTime | number | No | Last login time of the OS account. |
| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | No | Distributed account information. | | serialNumber | number | Yes | SN of the OS account. |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | No | Domain account information. | | isActived | boolean | Yes | Whether the OS account is activated. |
| isCreateCompleted | boolean | Yes | Whether the OS account information is complete. |
| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | No | Distributed account information. |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | No | Domain account information. |
## DomainAccountInfo ## DomainAccountInfo
Defines the domain account information. Domain account information.
| Name | Type | Mandatory| Description |
| ----------------- | ---------------------------------- | ---- | ------------------------ | **System capability**: SystemCapability.Account.OsAccount
| domain | string | Yes | Domain name. |
| accountName | string | Yes | Domain account name. | | Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ---------- |
| domain | string | Yes | Domain name. |
| accountName | string | Yes | Domain account name.|
## Constraints ## Constraints
| Constraint| Description| | Constraint | Description |
| ----------------- | ------------------- | | ------------------------------------- | ------------------------------ |
| constraint.wifi | A user is not allowed to use Wi-Fi.| | constraint.wifi | A user is not allowed to use Wi-Fi. |
| constraint.wifi.set | A user is not allowed to change Wi-Fi settings.| | constraint.wifi.set | A user is not allowed to change Wi-Fi settings. |
| constraint.locale.set | A user is not allowed to change the device language.| | constraint.locale.set | A user is not allowed to change the device language. |
| constraint.app.accounts | A user is not allowed to add or delete app accounts.| | constraint.app.accounts | A user is not allowed to add or delete app accounts. |
| constraint.apps.install | A user is not allowed to install apps.| | constraint.apps.install | A user is not allowed to install apps. |
| constraint.apps.uninstall | A user is not allowed to uninstall apps.| | constraint.apps.uninstall | A user is not allowed to uninstall apps. |
| constraint.location.shared | A user is not allowed to enable location sharing.| | constraint.location.shared | A user is not allowed to enable location sharing. |
| constraint.unknown.sources.install | A user is not allowed to install apps from unknown sources.| | constraint.unknown.sources.install | A user is not allowed to install apps from unknown sources. |
| constraint.global.unknown.app.install | All users are not allowed to install apps from unknown sources.| | constraint.global.unknown.app.install | All users are not allowed to install apps from unknown sources.|
| constraint.bluetooth.set | A user is not allowed to configure Bluetooth.| | constraint.bluetooth.set | A user is not allowed to configure Bluetooth. |
| constraint.bluetooth | The use of Bluetooth is prohibited on the device. | constraint.bluetooth | The use of Bluetooth is prohibited on the device.|
| constraint.bluetooth.share | Bluetooth sharing is prohibited.| | constraint.bluetooth.share | Bluetooth sharing is prohibited.|
| constraint.usb.file.transfer | A user is not allowed to transfer files over USB.| | constraint.usb.file.transfer | A user is not allowed to transfer files over USB.|
| constraint.credentials.set | A user is not allowed to configure user credentials.| | constraint.credentials.set | A user is not allowed to configure user credentials.|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册