提交 f67a5948 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 028fdcb7
......@@ -16,7 +16,7 @@ import wifiManager from '@ohos.enterprise.wifiManager';
isWifiActive(admin: Want, callback: AsyncCallback&lt;boolean&gt;): void
Checks whether Wi-Fi is enabled. This API uses an asynchronous callback to return the result.
Checks whether Wi-Fi is active. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SET_WIFI
......@@ -28,8 +28,8 @@ Checks whether Wi-Fi is enabled. This API uses an asynchronous callback to retur
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return whether Wi-Fi is enabled. |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application that checks the Wi-Fi status. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is a Boolean value (**true** indicates that Wi-Fi is active; and **false** indicates that Wi-Fi is inactive). If the operation fails, **err** is an error object. |
**Error codes**
......@@ -72,13 +72,13 @@ Checks whether Wi-Fi is active. This API uses a promise to return the result.
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application that checks the Wi-Fi status.|
**Return value**
| Type | Description |
| --------------------- | ------------------------- |
| Promise&lt;boolean&gt; | Promise used to return whether Wi-Fi is active. |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** indicates that Wi-Fi is active, and the value **false** indicates that Wi-Fi is inactive. |
**Error codes**
......@@ -102,3 +102,247 @@ wifiManager.isWifiActive(wantTemp).then((result) => {
console.log("error code:" + error.code + " error message:" + error.message);
});
```
## wifiManager.setWifiProfile
setWifiProfile(admin: Want, profile: WifiProfile, callback: AsyncCallback&lt;void&gt;): void
Sets Wi-Fi to connect to the specified network. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SET_WIFI
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application that sets the Wi-Fi profile. |
| profile | [WifiProfile](#wifiprofile) | Yes | WLAN configuration. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not an administrator application of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**Example**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let profile : WifiProfile = {
"ssid": "name",
"preSharedKey": "passwd",
"securityType": wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK
};
wifiManager.setWifiProfile(wantTemp, profile, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
return;
}
console.log("set wifi success");
});
```
## wifiManager.setWifiProfile
setWifiProfile(admin: Want, profile: WifiProfile): Promise&lt;void&gt;
Sets Wi-Fi to connect to the specified network. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SET_WIFI
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application that sets the Wi-Fi profile.|
| profile | [WifiProfile](#wifiprofile) | Yes | WLAN configuration. |
**Return value**
| Type | Description |
| --------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object is thrown.|
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not an administrator application of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**Example**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let profile : WifiProfile = {
"ssid": "name",
"preSharedKey": "passwd",
"securityType": wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK
};
wifiManager.isWifiActive(wantTemp, profile).then(() => {
console.log("set wifi success");
}).catch(error => {
console.log("error code:" + error.code + " error message:" + error.message);
});
```
## WifiProfile
Represents the WLAN configuration.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
| Name | Type | Readable| Writable | Description |
| ----------- | --------| ---- | ----- | ------------------------------- |
| ssid | string | Yes| No| Service set identifier (SSID) of the hotspot, in UTF-8 format.|
| bssid | string | Yes| No| Basic service set identifier (BSSID) of the hotspot.|
| preSharedKey | string | Yes| No| Pre-shared key (PSK) of the hotspot.|
| isHiddenSsid | boolean | Yes| No| Whether the network is hidden.|
| securityType | [WifiSecurityType](#wifisecuritytype) | Yes| No| Security type.|
| creatorUid | number | Yes| No| ID of the creator.|
| disableReason | number | Yes| No| Reason for disabling Wi-Fi.|
| netId | number | Yes| No| Network ID allocated.|
| randomMacType | number | Yes| No| Type of the random MAC.|
| randomMacAddr | string | Yes| No| Random MAC address.|
| ipType | [IpType](#iptype) | Yes| No| IP address type.|
| staticIp | [IpProfile](#ipprofile) | Yes| No| Static IP address information.|
| eapProfile | [WifiEapProfile](#wifieapprofile) | Yes| No| Extensible Authentication Protocol (EAP) configuration.|
## WifiSecurityType
Enumerates the Wi-Fi security types.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
| Name| Value| Description|
| -------- | -------- | -------- |
| WIFI_SEC_TYPE_INVALID | 0 | Invalid security type.|
| WIFI_SEC_TYPE_OPEN | 1 | Open security type.|
| WIFI_SEC_TYPE_WEP | 2 | Wired Equivalent Privacy (WEP).|
| WIFI_SEC_TYPE_PSK | 3 | PSK.|
| WIFI_SEC_TYPE_SAE | 4 | Simultaneous Authentication of Equals (SAE).|
| WIFI_SEC_TYPE_EAP | 5 | EAP.|
| WIFI_SEC_TYPE_EAP_SUITE_B | 6 | Suite B 192-bit encryption.|
| WIFI_SEC_TYPE_OWE | 7 | Opportunistic Wireless Encryption (OWE).|
| WIFI_SEC_TYPE_WAPI_CERT | 8 | WLAN Authentication and Privacy Infrastructure (WAPI) in certificate-based mode (WAPI-CERT).|
| WIFI_SEC_TYPE_WAPI_PSK | 9 | WAPI-PSK.|
## IpType
Enumerates the IP address types.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
| Name| Value| Description|
| -------- | -------- | -------- |
| STATIC | 0 | Static IP address.|
| DHCP | 1 | IP address allocated by DHCP.|
| UNKNOWN | 2 | Not specified.|
## IpProfile
Represents IP configuration information.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| ipAddress | number | Yes| No| IP address.|
| gateway | number | Yes| No| Gateway.|
| prefixLength | number | Yes| No| Subnet mask.|
| dnsServers | number[] | Yes| No| Domain name server (DNS) information.|
| domains | Array&lt;string&gt; | Yes| No| Domain information.|
## WifiEapProfile
Represents EAP profile (configuration) information.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
| **Name**| **Type**| **Readable**| **Writable**| **Description**|
| -------- | -------- | -------- | -------- | -------- |
| eapMethod | [EapMethod](#eapmethod) | Yes| No| EAP authentication method.|
| phase2Method | [Phase2Method](#phase2method) | Yes| No| Phase 2 authentication method.|
| identity | string | Yes| No| Identity Information.|
| anonymousIdentity | string | Yes| No| Anonymous identity.|
| password | string | Yes| No| Password.|
| caCertAliases | string | Yes| No| CA certificate alias.|
| caPath | string | Yes| No| CA certificate path.|
| clientCertAliases | string | Yes| No| Client certificate alias.|
| certEntry | Uint8Array | Yes| Yes| CA certificate content.|
| certPassword | string | Yes| Yes| CA certificate password.|
| altSubjectMatch | string | Yes| No| A string to match the alternate subject.|
| domainSuffixMatch | string | Yes| No| A string to match the domain suffix.|
| realm | string | Yes| No| Realm for the passpoint credential.|
| plmn | string | Yes| No| Public land mobile network (PLMN) of the passpoint credential provider.|
| eapSubId | number | Yes| No| Sub-ID of the SIM card.|
## EapMethod
Enumerates the EAP authentication methods.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
| Name| Value| Description|
| -------- | -------- | -------- |
| EAP_NONE | 0 | Not specified.|
| EAP_PEAP | 1 | PEAP.|
| EAP_TLS | 2 | TLS.|
| EAP_TTLS | 3 | TTLS.|
| EAP_PWD | 4 | Password.|
| EAP_SIM | 5 | SIM.|
| EAP_AKA | 6 | AKA.|
| EAP_AKA_PRIME | 7 | AKA Prime.|
| EAP_UNAUTH_TLS | 8 | UNAUTH TLS.|
## Phase2Method
Enumerates the Phase 2 authentication methods.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
| Name| Value| Description|
| -------- | -------- | -------- |
| PHASE2_NONE | 0 | Not specified.|
| PHASE2_PAP | 1 | PAP.|
| PHASE2_MSCHAP | 2 | MS-CHAP.|
| PHASE2_MSCHAPV2 | 3 | MS-CHAPv2.|
| PHASE2_GTC | 4 | GTC .|
| PHASE2_SIM | 5 | SIM.|
| PHASE2_AKA | 6 | AKA.|
| PHASE2_AKA_PRIME | 7 | AKA Prime.|
# @ohos.file.picker (File Picker)
The File Picker encapsulates system applications, such as **PhotoViewPicker**, **DocumentViewPicker**, and **AudioViewPicker**, and provides capabilities of selecting and saving photos, documents, and audio clips. The application can select the picker as required.
**Picker** encapsulates the system applications such as **PhotoViewPicker**, **DocumentViewPicker** and **AudioViewPicker** to provide capabilities of selecting and saving files of different types. The application can select the picker as required.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import picker from '@ohos.file.picker';
......@@ -28,7 +27,7 @@ let photoPicker = new picker.PhotoViewPicker();
select(option?: PhotoSelectOptions) : Promise&lt;PhotoSelectResult&gt;
Selects one or more images or videos in a **photoPicker** page. This API uses a promise to return the result. You can pass in **PhotoSelectOptions** to specify the media type and the maximum number of files to select.
Selects one or more images or videos in a **photoPicker** page. This API uses a promise to return the result. You can pass in **PhotoSelectOptions** to specify the media file type and the maximum number of files to select.
**System capability**: SystemCapability.FileManagement.UserFileService
......@@ -36,7 +35,7 @@ Selects one or more images or videos in a **photoPicker** page. This API uses a
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [PhotoSelectOptions](#photoselectoptions) | No | Options for selecting images or videos.|
| option | [PhotoSelectOptions](#photoselectoptions) | No | Options for selecting files. If this parameter is not specified, images and videos are selected by default. A maximum of 50 files can be selected.|
**Return value**
......@@ -68,7 +67,7 @@ async function example() {
select(option: PhotoSelectOptions, callback: AsyncCallback&lt;PhotoSelectResult&gt;) : void
Selects one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result. You can pass in **PhotoSelectOptions** to specify the media type and the maximum number of files to select.
Selects one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result. You can pass in **PhotoSelectOptions** to specify the media file type and the maximum number of files to select.
**System capability**: SystemCapability.FileManagement.UserFileService
......@@ -146,7 +145,7 @@ Saves one or more images or videos in a **photoPicker** page. This API uses a pr
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [PhotoSaveOptions](#photosaveoptions) | No | Options for saving images or videos.|
| option | [PhotoSaveOptions](#photosaveoptions) | No | Options for saving files. If this parameter is not specified, a **photoPicker** page will be displayed for the user to enter the names of the files to save.|
**Return value**
......@@ -266,7 +265,7 @@ Selects one or more documents in a **documentPicker** page. This API uses a prom
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [DocumentSelectOptions](#documentselectoptions) | No | Options for selecting documents.|
| option | [DocumentSelectOptions](#documentselectoptions) | No | Options for select documents. If this parameter is not specified, the **documentPicker** page is displayed by default.|
**Return value**
......@@ -373,7 +372,7 @@ Saves one or more documents in a **documentPicker** page. This API uses a promis
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [DocumentSaveOptions](#documentsaveoptions) | No | Options for saving the documents.|
| option | [DocumentSaveOptions](#documentsaveoptions) | No | Options for saving the documents. If this parameter is not specified, a **documentPicker** page will be displayed for the user to enter the names of the documents to save.|
**Return value**
......@@ -493,7 +492,7 @@ Selects one or more audio files in an **audioPicker** page (currently, a **docum
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [AudioSelectOptions](#audioselectoptions) | No | Options for selecting audio files.|
| option | [AudioSelectOptions](#audioselectoptions) | No | Options for selecting the audio files. If this parameter is not specified, the **audioPicker** page is displayed by default. |
**Return value**
......@@ -591,7 +590,7 @@ async function example() {
save(option?: AudioSaveOptions) : Promise&lt;Array&lt;string&gt;&gt;
Saves one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses a promise to return the result. You can pass in **AudioSaveOptions** to specify the file names of the audio clips to save.
Saves one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses a promise to return the result. You can pass in **AudioSaveOptions** to specify the names of the audio files to save.
**System capability**: SystemCapability.FileManagement.UserFileService
......@@ -599,7 +598,7 @@ Saves one or more audio files in an **audioPicker** page (currently, a **documen
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [AudioSaveOptions](#audiosaveoptions) | No | Options for saving audio files.|
| option | [AudioSaveOptions](#audiosaveoptions) | No | Options for saving audio files. If this parameter is not specified, an **audioPicker** page will be displayed for the user to enter the names of the files to save.|
**Return value**
......@@ -630,7 +629,7 @@ async function example() {
save(option: AudioSaveOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Saves one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses an asynchronous callback to return the result. You can pass in **AudioSaveOptions** to specify the file names of the audio clips to save.
Saves one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses an asynchronous callback to return the result. You can pass in **AudioSaveOptions** to specify the names of the audio files to save.
**System capability**: SystemCapability.FileManagement.UserFileService
......@@ -715,7 +714,7 @@ Defines the options for selecting images or videos.
| Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | -------------------------------- |
| MIMEType? | [PhotoViewMIMETypes](#photoviewmimetypes) | No | Media file types to select.|
| MIMEType? | [PhotoViewMIMETypes](#photoviewmimetypes) | No | Available media file types. **IMAGE_VIDEO_TYPE** is used by default.|
| maxSelectNumber? | number | No | Maximum number of media files to select. The default value is **50**, and the maximum value is **500**. |
## PhotoSelectResult
......@@ -727,7 +726,7 @@ Defines information about the images or videos selected.
| Name | Type | Readable| Writable| Description |
| ----------------------- | ------------------- | ---- | ---- | ------------------------------ |
| photoUris | Array&lt;string&gt; | Yes | Yes | URIs of the media files selected.|
| isOriginalPhoto | boolean | Yes | Yes | Whether the selected media file is the original image.|
| isOriginalPhoto | boolean | Yes | Yes | Whether the selected media file is the original image.|
## PhotoSaveOptions
......@@ -737,7 +736,7 @@ Defines the options for saving images or videos.
| Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ---------------------------- |
| newFileNames? | Array&lt;string&gt; | No | Files names of the images or videos to save.|
| newFileNames? | Array&lt;string&gt; | No | Names of the files to save. If this parameter is not specified, the user needs to enter the file names.|
## DocumentSelectOptions
......@@ -753,11 +752,11 @@ Defines the options for saving documents.
| Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ---------------------------- |
| newFileNames? | Array&lt;string&gt; | No | File names of the documents to save.|
| newFileNames? | Array&lt;string&gt; | No | Names of the documents to save. If this parameter is not specified, the user needs to enter the document names. |
## AudioSelectOptions
Defines the options for selecting audio clips. Currently, this parameter cannot be configured.
Defines the options for selecting audio files. Currently, this parameter cannot be configured.
**System capability**: SystemCapability.FileManagement.UserFileService
......@@ -769,4 +768,4 @@ Defines the options for saving audio files.
| Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ---------------------------- |
| newFileNames? | Array&lt;string&gt; | No | File names of the audio clips to save.|
| newFileNames? | Array&lt;string&gt; | No | Name of the audio files to save. If this parameter is not specified, the user needs to enter the file names.|
......@@ -4441,7 +4441,9 @@ Authenticates a domain account.
getAccountInfo: (domain, accountName, callback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => {},
bindAccount: (domainAccountInfo, localId, callback) => {},
unbindAccount: (domainAccountInfo, callback) => {}
unbindAccount: (domainAccountInfo, callback) => {},
isAccountTokenValid: (domainAccountInfo, callback) => {},
getAccessToken: (options, callback) => {}
}
account_osAccount.DomainAccountManager.registerPlugin(plugin);
let userAuth = new account_osAccount.UserAuth();
......@@ -4494,7 +4496,9 @@ Authenticates a domain account in a pop-up window.
getAccountInfo: (domain, accountName, callback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => {},
bindAccount: (domainAccountInfo, localId, callback) => {},
unbindAccount: (domainAccountInfo, callback) => {}
unbindAccount: (domainAccountInfo, callback) => {},
isAccountTokenValid: (domainAccountInfo, callback) => {},
getAccessToken: (options, callback) => {}
}
account_osAccount.DomainAccountManager.registerPlugin(plugin)
```
......@@ -4534,7 +4538,9 @@ Authenticates a domain account by the authorization token.
getAccountInfo: (domain, accountName, callback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => {},
bindAccount: (domainAccountInfo, localId, callback) => {},
unbindAccount: (domainAccountInfo, callback) => {}
unbindAccount: (domainAccountInfo, callback) => {},
isAccountTokenValid: (domainAccountInfo, callback) => {},
getAccessToken: (options, callback) => {}
}
account_osAccount.DomainAccountManager.registerPlugin(plugin)
```
......@@ -4576,7 +4582,9 @@ Obtains information about a domain account.
},
getAuthStatusInfo: (domainAccountInfo, callback) => {},
bindAccount: (domainAccountInfo, localId, callback) => {},
unbindAccount: (domainAccountInfo, callback) => {}
unbindAccount: (domainAccountInfo, callback) => {},
isAccountTokenValid: (domainAccountInfo, callback) => {},
getAccessToken: (options, callback) => {}
}
account_osAccount.DomainAccountManager.registerPlugin(plugin)
```
......@@ -4614,7 +4622,9 @@ Obtains the authentication status of a domain account.
})
},
bindAccount: (domainAccountInfo, localId, callback) => {},
unbindAccount: (domainAccountInfo, callback) => {}
unbindAccount: (domainAccountInfo, callback) => {},
isAccountTokenValid: (domainAccountInfo, callback) => {},
getAccessToken: (options, callback) => {}
}
account_osAccount.DomainAccountManager.registerPlugin(plugin)
```
......@@ -4649,7 +4659,9 @@ Binds a domain account.
// notify binding result
callback({code: 0})
},
unbindAccount: (domainAccountInfo, callback) => {}
unbindAccount: (domainAccountInfo, callback) => {},
isAccountTokenValid: (domainAccountInfo, callback) => {},
getAccessToken: (options, callback) => {}
}
account_osAccount.DomainAccountManager.registerPlugin(plugin)
```
......@@ -4684,6 +4696,84 @@ Unbinds a domain account.
// mock unbinding operation
// notify unbinding result
callback({code: 0})
},
isAccountTokenValid: (domainAccountInfo, callback) => {},
getAccessToken: (options, callback) => {}
}
account_osAccount.DomainAccountManager.registerPlugin(plugin)
```
### isAccountTokenValid<sup>10+</sup>
isAccountTokenValid(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: AsyncCallback&lt;boolean&gt;): void
Checks whether a domain account token is valid.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | --------------- |
| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.|
| token | Uint8Array | Yes| Domain account token to check.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result.|
**Example**
```js
let plugin = {
auth: (domainAccountInfo, credential, callback) => {},
authWithPopup: (domainAccountInfo, callback) => {},
authWithToken: (domainAccountInfo, callback) => {},
getAccountInfo: (domain, accountName, callback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => {},
bindAccount: (domainAccountInfo, localId, callback) => {},
unbindAccount: (domainAccountInfo, callback) => {},
isAccountTokenValid: (domainAccountInfo, callback) => {
// mock checking operation
// notify checking result
callback({code: 0}, true);
},
getAccessToken: (options, callback) => {}
}
account_osAccount.DomainAccountManager.registerPlugin(plugin)
```
### getAccessToken<sup>10+</sup>
getAccessToken(options: GetDomainAccessTokenOptions, callback: AsyncCallback&lt;Uint8Array&gt;): void
Obtains the domain access token based on the specified conditions.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | --------------- |
| options | [GetDomainAccessTokenOptions](#getdomainaccesstokenoptions10) | Yes | Options specified for obtaining the domain access token.|
| callback | AsyncCallback&lt;Uint8Array&gt; | Yes | Callback invoked to return the result.|
**Example**
```js
let plugin = {
auth: (domainAccountInfo, credential, callback) => {},
authWithPopup: (domainAccountInfo, callback) => {},
authWithToken: (domainAccountInfo, callback) => {},
getAccountInfo: (domain, accountName, callback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => {},
bindAccount: (domainAccountInfo, localId, callback) => {},
unbindAccount: (domainAccountInfo, callback) => {},
isAccountTokenValid: (domainAccountInfo, callback) => {},
getAccessToken: (options, callback) => {
// mock getting operation
let token = new Uint8Array([0]);
// notify result
callback({code: 0}, token);
}
}
account_osAccount.DomainAccountManager.registerPlugin(plugin)
......@@ -5003,6 +5093,107 @@ Checks whether a domain account exists.
}
```
### updateAccountToken<sup>10+</sup>
updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: AsyncCallback&lt;void&gt;): void;
Updates the token of a domain account. An empty token means an invalid token. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | --------------- |
| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.|
| token | Uint8Array | Yes | New token of the domain account.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result. If the token is successfully updated, **err** is **null**. Otherwise, **err** is an error object.|
**Error codes**
| ID| Error Message |
| -------- | --------------------------- |
| 12300001 | System service exception. |
| 12300002 | Invalid token. |
| 12300003 | Account not found. |
**Example**
```js
let domainAccountInfo = {
domain: "CHINA",
accountName: "zhangsan",
accountId: "123456"
}
let token = new Uint8Array([0])
try {
account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token, (err) => {
if (err != null) {
console.log("updateAccountToken failed, error: " + JSON.stringify(err));
} else {
console.log("updateAccountToken successfully");
}
})
} catch (err) {
console.log('updateAccountToken exception = ' + JSON.stringify(err));
}
```
### updateAccountToken<sup>10+</sup>
updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array): Promise&lt;void&gt;
Updates the token of a domain account. An empty token means an invalid token. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | --------------- |
| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.|
| token | Uint8Array | Yes | New token of the domain account.|
**Return value**
| Type | Description |
| :------------------------ | ----------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
| ID| Error Message |
| -------- | --------------------------- |
| 12300001 | System service exception. |
| 12300002 | Invalid token. |
| 12300003 | Account not found. |
**Example**
```js
let domainAccountInfo = {
domain: "CHINA",
accountName: "zhangsan",
accountId: "123456"
}
let token = new Uint8Array([0])
try {
account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token).then(() => {
console.log("updateAccountToken successfully");
}).catch((err) => {
console.log("updateAccountToken failed, error: " + JSON.stringify(err));
});
} catch (err) {
console.log('updateAccountToken exception = ' + JSON.stringify(err));
}
```
## UserIdentityManager<sup>8+</sup>
Provides APIs for user identity management (IDM).
......@@ -5956,7 +6147,7 @@ Defines the OS account information.
| localName | string | Yes | OS account name. |
| type | [OsAccountType](#osaccounttype) | Yes | OS account type. |
| constraints | Array&lt;string&gt; | No | [Constraints](#constraints) on the OS account.|
| isVerified<sup>8+</sup> | boolean | Yes | Whether the OS account is verified. |
| isVerified<sup>8+</sup> | boolean | Yes | Whether to verify the OS account. |
| photo<sup>8+</sup> | string | No | Profile photo of the OS account. |
| createTime<sup>8+</sup> | number | Yes | Time when the OS account was created. |
| lastLoginTime<sup>8+</sup> | number | No | Last login time of the OS account. |
......@@ -6086,3 +6277,18 @@ Presents the authentication status information.
| ----------- | ------ | ---- | ---------- |
| remainTimes | number | Yes | Number of remaining authentication times. |
| freezingTime | number | Yes | Freezing time.|
## GetDomainAccessTokenOptions<sup>10+</sup>
Defines the options for obtaining a domain access token.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ---------- |
| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information. |
| domainAccountToken | Uint8Array | Yes | Token of the domain account.|
| businessParams | { [key: string]: object } | Yes | Service parameters customized by the service party based on the request protocol.|
| callerUid | number | Yes | Unique identifier of the caller.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册