提交 e207d64e 编写于 作者: X xsz233 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into master

Signed-off-by: Nxsz233 <xushizhe@huawei.com>
...@@ -18,7 +18,7 @@ This repository stores device and application development documents provided by ...@@ -18,7 +18,7 @@ This repository stores device and application development documents provided by
- master: the latest version. - master: the latest version.
- OpenHarmony 3.2 Beta5. [Learn more](en/release-notes/OpenHarmony-v3.2-beta5.md) - OpenHarmony 3.2 Release. [Learn more](en/release-notes/OpenHarmony-v3.2-release.md)
- OpenHarmony 3.1 Release. [Learn more](en/release-notes/OpenHarmony-v3.1-release.md) - OpenHarmony 3.1 Release. [Learn more](en/release-notes/OpenHarmony-v3.1-release.md)
......
...@@ -36,7 +36,7 @@ Strong consistency has high requirements on distributed data management and may ...@@ -36,7 +36,7 @@ Strong consistency has high requirements on distributed data management and may
## Access Control Mechanism in Cross-Device Synchronization ## Access Control Mechanism in Cross-Device Synchronization
In the application data synchronization across devices, data access is controlled based on the device level and [data security label](access-control-by-device-and-data-level.md#data-security-label). In principle, data can be synchronized only to the devices whose data security labels are not higher than the device's security level. The access control matrix is as follows: In the application data synchronization across devices, data access is controlled based on the device level and [data security label](access-control-by-device-and-data-level.md#data-security-labels). In principle, data can be synchronized only to the devices whose data security labels are not higher than the device's security level. The access control matrix is as follows:
|Device Security Level|Data Security Labels of the Synchornizable Device| |Device Security Level|Data Security Labels of the Synchornizable Device|
|---|---| |---|---|
......
# Atomic Service Space Management (for System Applications Only)
Space management for atomic services is necessary from two aspects. On the one hand, users are unaware of the installation of atomic services and do not proactively uninstall them. On the other hand, atomic services have the [installation-free](../reference/apis/js-apis-freeInstall.md) feature, but they are not actually free of installation. This topic describes how to manage the space usage of atomic services for better system space usage.
## Managing Quota for Atomic Service Data Directories
Set a storage quota for the data sandbox directory of an atomic service. This quota can be obtained through the system parameter **persist.sys.bms.aging.policy.atomicservice.datasize.threshold**. The default value is 1024 MB. When the quota is used up, writing data will return an error message.
You can run the [param get/set](../../device-dev/subsystems/subsys-boot-init-plugin.md) command to view and set system parameters.
## Proactively Destroying Atomic Services
To proactively destroy an atomic service, call the [uninstall](../reference/apis/js-apis-installer.md#bundleinstalleruninstall) API.
**Example**
```ts
import installer from '@ohos.bundle.installer';
let bundleName = 'com.ohos.demo';
let installParam = {
userId: 100
};
try {
installer.getBundleInstaller().then(data => {
data.uninstall(bundleName, installParam, err => {
if (err) {
console.error('uninstall failed:' + err.message);
} else {
console.info('uninstall successfully.');
}
});
}).catch(error => {
console.error('getBundleInstaller failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getBundleInstaller failed. Cause: ' + error.message);
}
```
## Automatically Destroying Atomic Services
### Automatic Destruction Time
Automatic destruction of atomic services can be triggered in any of the following conditions:
- When a timer is set and the given interval has elapsed. The timer interval can be obtained through the system parameter **persist.sys.bms.aging.policy.timer.interval**, which is 8 hours by default. The remaining battery level must be greater than or equal to the value of **persist.sys.bms.aging.policy.battery.threshold**, which is 10% by default.
- When an atomic service is installed.
- When the clearance flag of an atomic service is modified.
### Destruction Conditions
#### Prerequisites
- [isHapModuleRemovable](../reference/apis/js-apis-freeInstall.md#ishapmoduleremovable) is set to **true**.
- The atomic service is not running.
#### Condition for Starting Destruction
The space occupied by all atomic services (including their installation and data directories) is greater than the value of **persist.sys.bms.aging.policy.data.size.threshold**, which is 500 MB by default.
#### Condition for Ending Destruction
The space occupied by all atomic services (including the installation and data directories) is less than 80% of the value of **persist.sys.bms.aging.policy.data.size.threshold**.
### Automatic Destruction Sequence
- Atomic services that can be destroyed are classified into different time slots based on the last used time, for example, [0, 10), [10, 20), [20, 30), [30, ~). The time slot unit can be obtained from the system parameter **persist.sys.bms.aging.policy.recently.used.threshold**, which is 1 day by default.
- For any two atomic services that can be destroyed, if they are in the same time slot, the atomic service that is less used is destroyed first; if they are in different time slots, the atomic service that is not used for a longer time is destroyed first.
### Automatic Destruction by Level
- When the condition for starting automatic destruction is met, the cache directories of the atomic services are destroyed first based on the destruction sequence. If the condition for ending destruction is met, the destruction is ended.
- If the condition for ending destruction is not met, the other directories of the atomic service are destroyed based on the destruction sequence.
...@@ -932,6 +932,11 @@ Indicates that the HTTP proxy configuration has changed. ...@@ -932,6 +932,11 @@ Indicates that the HTTP proxy configuration has changed.
- Value: **usual.event.HTTP_PROXY_CHANGE** - Value: **usual.event.HTTP_PROXY_CHANGE**
- Required subscriber permissions: none - Required subscriber permissions: none
## COMMON_EVENT_DOMAIN_ACCOUNT_STATUS_CHANGED<sup>10+<sup>
Indicates that the domain account status has changed.
- Value: **usual.event.DOMAIN_ACCOUNT_STATUS_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_SIM_STATE_CHANGED<sup>10+<sup> ## COMMON_EVENT_SIM_STATE_CHANGED<sup>10+<sup>
Indicates that the SIM card state has changed. Indicates that the SIM card state has changed.
- Value: **usual.event.SIM_STATE_CHANGED** - Value: **usual.event.SIM_STATE_CHANGED**
......
...@@ -122,6 +122,14 @@ Deregisters a mission status listener. ...@@ -122,6 +122,14 @@ Deregisters a mission status listener.
| listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **on()**.| | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **on()**.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300002 | Input error. The specified mission listener does not exist. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -209,6 +217,14 @@ Deregisters a mission status listener. This API uses a promise to return the res ...@@ -209,6 +217,14 @@ Deregisters a mission status listener. This API uses a promise to return the res
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300002 | Input error. The specified mission listener does not exist. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -624,6 +640,14 @@ Locks a given mission. This API uses an asynchronous callback to return the resu ...@@ -624,6 +640,14 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
| missionId | number | Yes| Mission ID.| | missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -667,6 +691,14 @@ Locks a given mission. This API uses a promise to return the result. ...@@ -667,6 +691,14 @@ Locks a given mission. This API uses a promise to return the result.
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
import missionManager from '@ohos.app.ability.missionManager'; import missionManager from '@ohos.app.ability.missionManager';
...@@ -702,6 +734,14 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re ...@@ -702,6 +734,14 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re
| missionId | number | Yes| Mission ID.| | missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
import missionManager from '@ohos.app.ability.missionManager'; import missionManager from '@ohos.app.ability.missionManager';
...@@ -744,6 +784,14 @@ Unlocks a given mission. This API uses a promise to return the result. ...@@ -744,6 +784,14 @@ Unlocks a given mission. This API uses a promise to return the result.
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -924,6 +972,14 @@ Switches a given mission to the foreground. This API uses an asynchronous callba ...@@ -924,6 +972,14 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
| missionId | number | Yes| Mission ID.| | missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -963,6 +1019,14 @@ Switches a given mission to the foreground, with the startup parameters for the ...@@ -963,6 +1019,14 @@ Switches a given mission to the foreground, with the startup parameters for the
| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.| | options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -1007,6 +1071,14 @@ Switches a given mission to the foreground, with the startup parameters for the ...@@ -1007,6 +1071,14 @@ Switches a given mission to the foreground, with the startup parameters for the
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
......
...@@ -32,12 +32,12 @@ import StartOptions from '@ohos.app.ability.StartOptions'; ...@@ -32,12 +32,12 @@ import StartOptions from '@ohos.app.ability.StartOptions';
try { try {
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error) {
console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}'); console.error(`getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}`);
return; return;
} }
console.log('size = ${missions.length}'); console.log(`size = ${missions.length}`);
console.log('missions = ${JSON.stringify(missions)}'); console.log(`missions = ${JSON.stringify(missions)}`);
let id = missions[0].missionId; let id = missions[0].missionId;
let startOptions = { let startOptions = {
...@@ -45,10 +45,10 @@ import StartOptions from '@ohos.app.ability.StartOptions'; ...@@ -45,10 +45,10 @@ import StartOptions from '@ohos.app.ability.StartOptions';
displayId: 0 displayId: 0
}; };
missionManager.moveMissionToFront(id, startOptions).then(() => { missionManager.moveMissionToFront(id, startOptions).then(() => {
console.log('moveMissionToFront is called '); console.log('moveMissionToFront is called');
}); });
}); });
} catch (paramError) { } catch (paramError) {
console.error('error: ${paramError.code}, ${paramError.message}'); console.error(`error: ${paramError.code}, ${paramError.message}`);
} }
``` ```
...@@ -9,6 +9,7 @@ The **ApplicationInfo** module defines the application information. A system app ...@@ -9,6 +9,7 @@ The **ApplicationInfo** module defines the application information. A system app
## ApplicationInfo ## ApplicationInfo
**System capability**: SystemCapability.BundleManager.BundleFramework.Core **System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| -------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | | -------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| name | string | Yes | No | Application name. | | name | string | Yes | No | Application name. |
...@@ -33,3 +34,4 @@ The **ApplicationInfo** module defines the application information. A system app ...@@ -33,3 +34,4 @@ The **ApplicationInfo** module defines the application information. A system app
| appProvisionType | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**. | | appProvisionType | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**. |
| systemApp | boolean | Yes | No | Whether the application is a system application. | | systemApp | boolean | Yes | No | Whether the application is a system application. |
| bundleType |[BundleType](js-apis-bundleManager.md#bundletype) | Yes | No | Bundle type, which can be **APP** (common application) or **ATOMIC_SERVICE** (atomic service). | | bundleType |[BundleType](js-apis-bundleManager.md#bundletype) | Yes | No | Bundle type, which can be **APP** (common application) or **ATOMIC_SERVICE** (atomic service). |
| debug<sup>10+</sup> | boolean | Yes | No | Whether the application is in debugging mode. The default value is **false**. |
# BusinessAbilityInfo
> **NOTE**
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The **BusinessAbilityInfo** module provides basic information about a business ability.
## BusinessAbilityInfo
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Type | Readable| Writable| Description |
| --------------------------------- | ------------------------------------------------------------ | ---- | ---- | -------------------- |
| bundleName | string | Yes | No | Bundle name.|
| moduleName | string | Yes | No | Module name.|
| name | string | Yes | No | Name of the business ability.|
| labelId | number | Yes | No | Label ID of the module. |
| descriptionId | number | Yes | No | Description ID of the module. |
| iconId | number | Yes | No | ID of the icon that describes the ability information.|
| businessType | [businessAbilityRouter.BusinessType](js-apis-businessAbilityRouter.md#businesstype) | Yes| No| Type of the business ability.|
| applicationInfo | Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Yes | No | Application information. |
# @ohos.app.businessAbilityRouter (Business Ability Router)
The **businessAbilityRouter** module provides APIs for you to query the business ability information of applications installed on the device. It provides a unified template for you to register standard services by type. Based on the information, a system application or third-party application can obtain services that meet certain criteria and select a proper service. The module also provides unified rules to manage redirection between applications and services. It prevents arbitrary switching between the foreground and background and avoids the distribution of third-party applications by means of redirection.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The APIs provided by this module are system APIs.
## Modules to Import
``` ts
import businessAbilityRouter from '@ohos.app.businessAbilityRouter';
```
## Required Permissions
| Permission | Permission Level | Description |
| ------------------------------------------ | ------------ | -------------------- |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | Permission to query information about all bundles.|
For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels).
## BusinessType
Enumerates the types of business abilities.
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
**System API**: This is a system API.
| Name | Value | Description |
| ----------- | ---- | ------------------------------------ |
| SHARE | 0 | Business ability of the share type.|
| UNSPECIFIED | 255 | Business ability of an unspecified type. |
## BusinessAbilityFilter
Describes the criteria for filtering business abilities.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
**System API**: This is a system API.
| Name | Type | Readable| Writable| Description |
| ------------ | ------------ | ---- | ---- | -------------------------------------- |
| businessType | BusinessType | Yes | No | Type of the business ability. |
| mimeType | string | Yes | No | MIME type supported by the business ability.|
| uri | string | Yes | No | URI supported by the business ability. |
## businessAbilityRouter.queryBusinessAbilityInfo
queryBusinessAbilityInfo(filter: BusinessAbilityFilter, callback: AsyncCallback\<Array\<BusinessAbilityInfo\>\>): void;
Obtains the business ability information based on the specified filter criteria. This API uses an asynchronous callback to return the result. If the operation is successful, the business ability information is returned; otherwise, an error object is returned.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | --------------------------------------- |
| filter | [BusinessAbilityFilter](#businessabilityfilter) | Yes | Object used to filter the business abilities.|
| callback | AsyncCallback\<Array\<[BusinessAbilityInfo](js-apis-bundleManager-businessAbilityInfo.md#businessabilityinfo)\>\> | Yes| Callback used to return the result. If the operation is successful, the business ability information that meets the filter criteria is returned; otherwise, an error object is returned.|
**Example**
```ts
import businessAbilityRouter from '@ohos.app.businessAbilityRouter';
let filter = {businessType: businessAbilityRouter.BusinessType.SHARE};
try {
businessAbilityRouter.queryBusinessAbilityInfo(filter)
.then(() => {
console.info('queryBusinessAbilityInfo success');
}).catch((error) => {
console.error('queryBusinessAbilityInfo failed ' + error.message);
});
} catch (error) {
console.error('queryBusinessAbilityInfo failed ' + error.message);
}
```
## businessAbilityRouter.queryBusinessAbilityInfo
queryBusinessAbilityInfo(filter: BusinessAbilityFilter): Promise\<Array\<BusinessAbilityInfo\>\>;
Obtains the business ability information based on the specified filter criteria. This API uses a promise to return the result. If the operation is successful, the business ability information is returned; otherwise, an error object is returned.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | ------------------------------- | ---- | --------------------------------------- |
| filter | [BusinessAbilityFilter](#businessabilityfilter) | Yes | Object used to filter the business abilities. |
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ------------------------------------------- |
| Promise\<Array\<[BusinessAbilityInfo](js-apis-bundleManager-businessAbilityInfo.md#businessabilityinfo)\>\> | Promise used to return the business ability information that meets the filter criteria.|
**Example**
```ts
import businessAbilityRouter from '@ohos.app.businessAbilityRouter';
let filter = {businessType: businessAbilityRouter.BusinessType.SHARE};
try {
businessAbilityRouter.queryBusinessAbilityInfo(filter, (error, data) => {
if (error) {
console.error('queryBusinessAbilityInfo failed ' + error.message);
return;
}
console.info('queryBusinessAbilityInfo success');
});
} catch (error) {
console.error('queryBusinessAbilityInfo failed ' + error.message);
}
```
...@@ -20,9 +20,7 @@ For details about the definitions of all system common events, see [System Commo ...@@ -20,9 +20,7 @@ For details about the definitions of all system common events, see [System Commo
## CommonEventManager.publish ## CommonEventManager.publish
```ts publish(event: string, callback: AsyncCallback\<void>): void
publish(event: string, callback: AsyncCallback<void>): void
```
Publishes a common event and executes an asynchronous callback after the event is published. Publishes a common event and executes an asynchronous callback after the event is published.
...@@ -37,7 +35,15 @@ Publishes a common event and executes an asynchronous callback after the event i ...@@ -37,7 +35,15 @@ Publishes a common event and executes an asynchronous callback after the event i
**Error codes** **Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. |
**Example** **Example**
...@@ -61,9 +67,7 @@ try { ...@@ -61,9 +67,7 @@ try {
## CommonEventManager.publish ## CommonEventManager.publish
```ts publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
publish(event: string, options: CommonEventPublishData, callback: AsyncCallback<void>): void
```
Publishes a common event with given attributes. This API uses an asynchronous callback to return the result. Publishes a common event with given attributes. This API uses an asynchronous callback to return the result.
...@@ -79,7 +83,15 @@ Publishes a common event with given attributes. This API uses an asynchronous ca ...@@ -79,7 +83,15 @@ Publishes a common event with given attributes. This API uses an asynchronous ca
**Error codes** **Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. |
**Example** **Example**
...@@ -110,9 +122,7 @@ try { ...@@ -110,9 +122,7 @@ try {
## CommonEventManager.publishAsUser<sup> ## CommonEventManager.publishAsUser<sup>
```ts publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): void
publishAsUser(event: string, userId: number, callback: AsyncCallback<void>): void
```
Publishes a common event to a specific user. This API uses an asynchronous callback to return the result. Publishes a common event to a specific user. This API uses an asynchronous callback to return the result.
...@@ -130,7 +140,16 @@ Publishes a common event to a specific user. This API uses an asynchronous callb ...@@ -130,7 +140,16 @@ Publishes a common event to a specific user. This API uses an asynchronous callb
**Error codes** **Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. |
**Example** **Example**
...@@ -157,9 +176,7 @@ try { ...@@ -157,9 +176,7 @@ try {
## CommonEventManager.publishAsUser ## CommonEventManager.publishAsUser
```ts publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback<void>): void
```
Publishes a common event with given attributes to a specific user. This API uses an asynchronous callback to return the result. Publishes a common event with given attributes to a specific user. This API uses an asynchronous callback to return the result.
...@@ -178,7 +195,16 @@ Publishes a common event with given attributes to a specific user. This API uses ...@@ -178,7 +195,16 @@ Publishes a common event with given attributes to a specific user. This API uses
**Error codes** **Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. |
**Example** **Example**
...@@ -212,9 +238,7 @@ try { ...@@ -212,9 +238,7 @@ try {
## CommonEventManager.createSubscriber ## CommonEventManager.createSubscriber
```ts createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void
createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback<CommonEventSubscriber>): void
```
Creates a subscriber. This API uses an asynchronous callback to return the result. Creates a subscriber. This API uses an asynchronous callback to return the result.
...@@ -227,6 +251,14 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul ...@@ -227,6 +251,14 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul
| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. |
| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**Example** **Example**
...@@ -258,9 +290,7 @@ try { ...@@ -258,9 +290,7 @@ try {
## CommonEventManager.createSubscriber ## CommonEventManager.createSubscriber
```ts createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber>
createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise<CommonEventSubscriber>
```
Creates a subscriber. This API uses a promise to return the result. Creates a subscriber. This API uses a promise to return the result.
...@@ -277,6 +307,14 @@ Creates a subscriber. This API uses a promise to return the result. ...@@ -277,6 +307,14 @@ Creates a subscriber. This API uses a promise to return the result.
| --------------------------------------------------------- | ---------------- | | --------------------------------------------------------- | ---------------- |
| Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Promise used to return the subscriber object.| | Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Promise used to return the subscriber object.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**Example** **Example**
```ts ```ts
...@@ -299,9 +337,7 @@ CommonEventManager.createSubscriber(subscribeInfo).then((commonEventSubscriber) ...@@ -299,9 +337,7 @@ CommonEventManager.createSubscriber(subscribeInfo).then((commonEventSubscriber)
## CommonEventManager.subscribe ## CommonEventManager.subscribe
```ts subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback<CommonEventData>): void
```
Subscribes to common events. This API uses an asynchronous callback to return the result. Subscribes to common events. This API uses an asynchronous callback to return the result.
...@@ -314,6 +350,17 @@ Subscribes to common events. This API uses an asynchronous callback to return th ...@@ -314,6 +350,17 @@ Subscribes to common events. This API uses an asynchronous callback to return th
| subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | Yes | Subscriber object. | | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | Yes | Subscriber object. |
| callback | AsyncCallback\<[CommonEventData](./js-apis-inner-commonEvent-commonEventData.md)> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[CommonEventData](./js-apis-inner-commonEvent-commonEventData.md)> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
**Example** **Example**
```ts ```ts
...@@ -360,9 +407,7 @@ try { ...@@ -360,9 +407,7 @@ try {
## CommonEventManager.unsubscribe ## CommonEventManager.unsubscribe
```ts unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void
unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback<void>): void
```
Unsubscribes from common events. This API uses an asynchronous callback to return the result. Unsubscribes from common events. This API uses an asynchronous callback to return the result.
...@@ -375,6 +420,17 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur ...@@ -375,6 +420,17 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur
| subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | Yes | Subscriber object. | | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | Yes | Subscriber object. |
| callback | AsyncCallback\<void> | No | Callback used to return the result.| | callback | AsyncCallback\<void> | No | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
**Example** **Example**
```ts ```ts
...@@ -428,3 +484,93 @@ try { ...@@ -428,3 +484,93 @@ try {
console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`); console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} }
``` ```
## CommonEventManager.removeStickyCommonEvent<sup>10+</sup>
removeStickyCommonEvent(event: string, callback: AsyncCallback\<void>): void
Removes a sticky common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Required permissions**: ohos.permission.COMMONEVENT_STICKY
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------------------- |
| event | string | Yes | Sticky common event to remove. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 201 | The application dose not have permission to call the interface. |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not system service. |
| 1500007 | The message send error. |
| 1500008 | The CEMS error. |
**Example**
```ts
CommonEventManager.removeStickyCommonEvent("sticky_event", (err) => {
if (err) {
console.info(`Remove sticky event AsyncCallback failed, errCode: ${err.code}, errMes: ${err.message}`);
return;
}
console.info(`Remove sticky event AsyncCallback success`);
}
});
```
## CommonEventManager.removeStickyCommonEvent<sup>10+</sup>
removeStickyCommonEvent(event: string): Promise\<void>
Removes a sticky common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Required permissions**: ohos.permission.COMMONEVENT_STICKY
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------- |
| event | string | Yes | Sticky common event to remove.|
**Return value**
| Type | Description |
| -------------- | ---------------------------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 201 | The application dose not have permission to call the interface. |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not system service. |
| 1500007 | The message send error. |
| 1500008 | The CEMS error. |
**Example**
```ts
commonEventManager.removeStickyCommonEvent("sticky_event").then(() => {
console.info(`Remove sticky event AsyncCallback success`);
}).catch ((err) => {
console.info(`Remove sticky event AsyncCallback failed, errCode: ${err.code}, errMes: ${err.message}`);
});
```
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
The **AppStateData** module defines the application state data, which can be obtained through [getForegroundApplications](js-apis-app-ability-appManager.md#appmanagergetforegroundapplications). The **AppStateData** module defines the application state data, which can be obtained through [getForegroundApplications](js-apis-app-ability-appManager.md#appmanagergetforegroundapplications).
## Modules to Import
```ts
import appManager from '@ohos.app.ability.appManager';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This module is marked as @systemapi and not visible to third-party applications. **System API**: This module is marked as @systemapi and not visible to third-party applications.
...@@ -19,8 +25,8 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -19,8 +25,8 @@ import appManager from '@ohos.app.ability.appManager';
function getForegroundAppInfos() { function getForegroundAppInfos() {
appManager.getForegroundApplications((error, data) => { appManager.getForegroundApplications((error, data) => {
if (error && error.code) { if (error) {
console.log('getForegroundApplications failed, error.code: ${error.code}, error.message: ${error.message}'); console.log('getForegroundApplications failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
......
...@@ -7,6 +7,12 @@ The **Context** module provides context for abilities or applications. It allows ...@@ -7,6 +7,12 @@ The **Context** module provides context for abilities or applications. It allows
> - 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. > - 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.
> - The APIs of this module can be used only in the stage model. > - The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import common from '@ohos.app.ability.common';
```
## Attributes ## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -20,7 +26,7 @@ The **Context** module provides context for abilities or applications. It allows ...@@ -20,7 +26,7 @@ The **Context** module provides context for abilities or applications. It allows
| filesDir | string | Yes | No | File directory.| | filesDir | string | Yes | No | File directory.|
| databaseDir | string | Yes | No | Database directory.| | databaseDir | string | Yes | No | Database directory.|
| preferencesDir | string | Yes | No | Preferences directory.| | preferencesDir | string | Yes | No | Preferences directory.|
| bundleCodeDir | string | Yes | No | Bundle code directory.| | bundleCodeDir | string | Yes | No | Bundle code directory. Do not access resource files by concatenating paths. Use the [resourceManager API](js-apis-resource-manager.md) instead.|
| distributedFilesDir | string | Yes | No | Distributed file directory.| | distributedFilesDir | string | Yes | No | Distributed file directory.|
| eventHub | [EventHub](js-apis-inner-application-eventHub.md) | Yes | No | Event hub that implements event subscription, unsubscription, and triggering.| | eventHub | [EventHub](js-apis-inner-application-eventHub.md) | Yes | No | Event hub that implements event subscription, unsubscription, and triggering.|
| area | contextConstant.[AreaMode](js-apis-app-ability-contextConstant.md) | Yes | No | Area in which the file to be access is located.| | area | contextConstant.[AreaMode](js-apis-app-ability-contextConstant.md) | Yes | No | Area in which the file to be access is located.|
...@@ -47,18 +53,10 @@ Creates the context based on the bundle name. ...@@ -47,18 +53,10 @@ Creates the context based on the bundle name.
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
let bundleContext; let bundleContext: common.Context;
try { try {
bundleContext = this.context.createBundleContext('com.example.test'); bundleContext = this.context.createBundleContext('com.example.test');
} catch (error) { } catch (error) {
...@@ -86,18 +84,10 @@ Creates the context based on the module name. ...@@ -86,18 +84,10 @@ Creates the context based on the module name.
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
let moduleContext; let moduleContext: common.Context;
try { try {
moduleContext = this.context.createModuleContext('entry'); moduleContext = this.context.createModuleContext('entry');
} catch (error) { } catch (error) {
...@@ -126,18 +116,10 @@ Creates the context based on the bundle name and module name. ...@@ -126,18 +116,10 @@ Creates the context based on the bundle name and module name.
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
let moduleContext; let moduleContext: common.Context;
try { try {
moduleContext = this.context.createModuleContext('com.example.test', 'entry'); moduleContext = this.context.createModuleContext('com.example.test', 'entry');
} catch (error) { } catch (error) {
...@@ -162,7 +144,7 @@ Obtains the context of this application. ...@@ -162,7 +144,7 @@ Obtains the context of this application.
**Example** **Example**
```ts ```ts
let applicationContext; let applicationContext: common.Context;
try { try {
applicationContext = this.context.getApplicationContext(); applicationContext = this.context.getApplicationContext();
} catch (error) { } catch (error) {
......
...@@ -7,6 +7,12 @@ The **ExtensionRunningInfo** module encapsulates ExtensionAbility running inform ...@@ -7,6 +7,12 @@ The **ExtensionRunningInfo** module encapsulates ExtensionAbility running inform
> - 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. > - 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.
> - This module is marked as @systemapi and not visible to third-party applications. > - This module is marked as @systemapi and not visible to third-party applications.
## Modules to Import
```ts
import abilityManager from '@ohos.app.ability.abilityManager';
```
## Usage ## Usage
Import the **abilityManager** module and obtain the ExtensionAbility running information by calling the method in the **abilityManager** module. Import the **abilityManager** module and obtain the ExtensionAbility running information by calling the method in the **abilityManager** module.
...@@ -32,8 +38,8 @@ import abilityManager from '@ohos.app.ability.abilityManager'; ...@@ -32,8 +38,8 @@ import abilityManager from '@ohos.app.ability.abilityManager';
let upperLimit = 1; let upperLimit = 1;
function getExtensionInfos() { function getExtensionInfos() {
abilityManager.getExtensionRunningInfos(upperLimit, (error, data) => { abilityManager.getExtensionRunningInfos(upperLimit, (error, data) => {
if (error && error.code) { if (error) {
console.error('getForegroundApplications failed, error.code: ${error.code}, error.message: ${error.message}'); console.error('getForegroundApplications failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
......
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
The **MissionInfo** module defines detailed information about a mission. The information can be obtained through [getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo). The **MissionInfo** module defines detailed information about a mission. The information can be obtained through [getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo).
## Modules to Import
```ts
import missionManager from '@ohos.app.ability.missionManager';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
...@@ -23,7 +29,7 @@ import missionManager from '@ohos.app.ability.missionManager'; ...@@ -23,7 +29,7 @@ import missionManager from '@ohos.app.ability.missionManager';
try { try {
missionManager.getMissionInfo('', 1, (error, data) => { missionManager.getMissionInfo('', 1, (error, data) => {
if (error.code) { if (error) {
// Process service logic errors. // Process service logic errors.
console.error('getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}'); console.error('getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
......
...@@ -7,6 +7,12 @@ The **MissionSnapshot** module defines the snapshot of a mission. The snapshot c ...@@ -7,6 +7,12 @@ The **MissionSnapshot** module defines the snapshot of a mission. The snapshot c
> The initial APIs of this module are supported since API version 8. 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 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module are system APIs and cannot be called by third-party applications. > The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import
```ts
import missionManager from '@ohos.app.ability.missionManager';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
...@@ -26,8 +32,8 @@ The mission snapshot information can be obtained by using **getMissionSnapShot** ...@@ -26,8 +32,8 @@ The mission snapshot information can be obtained by using **getMissionSnapShot**
try { try {
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error) {
console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}'); console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -35,8 +41,8 @@ The mission snapshot information can be obtained by using **getMissionSnapShot** ...@@ -35,8 +41,8 @@ The mission snapshot information can be obtained by using **getMissionSnapShot**
let id = missions[0].missionId; let id = missions[0].missionId;
missionManager.getMissionSnapShot('', id, (err, snapshot) => { missionManager.getMissionSnapShot('', id, (err, snapshot) => {
if (err.code) { if (err) {
console.error('getMissionInfos failed, err.code: ${err.code}, err.message: ${err.message}'); console.error('getMissionInfos failed, err.code: ${JSON.stringify(err.code)}, err.message: ${JSON.stringify(err.message)}');
return; return;
} }
......
...@@ -351,7 +351,7 @@ Enumerates the reasons for the state transition of the **AVPlayer** or **AVRecor ...@@ -351,7 +351,7 @@ Enumerates the reasons for the state transition of the **AVPlayer** or **AVRecor
A playback management class that provides APIs to manage and play media assets. Before calling any API in **AVPlayer**, you must use [createAVPlayer()](#mediacreateavplayer9) to create an **AVPlayer** instance. A playback management class that provides APIs to manage and play media assets. Before calling any API in **AVPlayer**, you must use [createAVPlayer()](#mediacreateavplayer9) to create an **AVPlayer** instance.
For details about the AVPlayer demo, see [AVPlayer Development](../../media/avplayer-playback.md). For details about the audio and video playback demo, see [Audio Playback](../../media/using-avplayer-for-playback.md) and [Video Playback](../../media/video-playback.md).
### Attributes<a name=avplayer_attributes></a> ### Attributes<a name=avplayer_attributes></a>
...@@ -475,9 +475,9 @@ The AVPlayer provides the following error types<a name = error_info></a>: ...@@ -475,9 +475,9 @@ The AVPlayer provides the following error types<a name = error_info></a>:
| 801 | Unsupport Capability: | Unsupported API, causing an invalid call. | | 801 | Unsupport Capability: | Unsupported API, causing an invalid call. |
| 5400101 | No Memory: | Insufficient memory. The [AVPlayer state](#avplayerstate9) is error.| | 5400101 | No Memory: | Insufficient memory. The [AVPlayer state](#avplayerstate9) is error.|
| 5400102 | Operate Not Permit: | Unsupported operation in the current state, causing an invalid call. | | 5400102 | Operate Not Permit: | Unsupported operation in the current state, causing an invalid call. |
| 5400103 | IO Error: | Abnormal stream. | | 5400103 | IO Error: | A stream exception is detected during playback. The [AVPlayer state](#avplayerstate9) is error.|
| 5400104 | Network Timeout: | The response times out due to a network error. The [AVPlayer state](#avplayerstate9) is error.| | 5400104 | Network Timeout: | The response times out due to a network error. The [AVPlayer state](#avplayerstate9) is error.|
| 5400105 | Service Died: | The playback process is dead. The [AVPlayer state](#avplayerstate9) is error.| | 5400105 | Service Died: | The playback process is dead. The [AVPlayer state](#avplayerstate9) is error. In this case, you need to release the instance and then create an instance again.|
| 5400106 | Unsupport Format: | Unsupported file format. The [AVPlayer state](#avplayerstate9) is error.| | 5400106 | Unsupport Format: | Unsupported file format. The [AVPlayer state](#avplayerstate9) is error.|
**Example** **Example**
...@@ -1139,7 +1139,7 @@ Sets the bit rate, which is valid only for HTTP Live Streaming (HLS) streams. Th ...@@ -1139,7 +1139,7 @@ Sets the bit rate, which is valid only for HTTP Live Streaming (HLS) streams. Th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------------------------------------------------------ | | ------- | ------ | ---- | ------------------------------------------------------------ |
| bitrate | number | Yes | Bit rate to set. You can obtain the available bit rates of the current HLS stream by subscribing to the [availableBitrates](#availableBitrates_on) event. If the bit rate to set is not in the list of the available bit rates, the AVPlayer selects from the list the minimum bit rate that is closed to the bit rate to set.| | bitrate | number | Yes | Bit rate to set. You can obtain the available bit rates of the current HLS stream by subscribing to the [availableBitrates](#availableBitrates_on) event. If the bit rate to set is not in the list of the available bit rates, the AVPlayer selects from the list the minimum bit rate that is closed to the bit rate to set. If the length of the available bit rate list obtained through the event is 0, no bit rate can be set and the **bitrateDone** callback will not be triggered.|
**Example** **Example**
...@@ -1204,7 +1204,7 @@ Subscribes to available bit rates of HLS streams. This event is reported only af ...@@ -1204,7 +1204,7 @@ Subscribes to available bit rates of HLS streams. This event is reported only af
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ | | -------- | -------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type, which is **'availableBitrates'** in this case. This event is triggered once after the AVPlayer switches to the prepared state.| | type | string | Yes | Event type, which is **'availableBitrates'** in this case. This event is triggered once after the AVPlayer switches to the prepared state.|
| callback | function | Yes | Callback invoked when the event is triggered. It returns an array that holds the available bit rates.| | callback | function | Yes | Callback invoked when the event is triggered. It returns an array that holds the available bit rates. If the array length is 0, no bit rate can be set.|
**Example** **Example**
...@@ -1603,7 +1603,7 @@ avPlayer.off('audioInterrupt') ...@@ -1603,7 +1603,7 @@ avPlayer.off('audioInterrupt')
## AVPlayerState<sup>9+</sup><a name = avplayerstate></a> ## AVPlayerState<sup>9+</sup><a name = avplayerstate></a>
Enumerates the states of the [AVPlayer](#avplayer9). Your application can proactively obtain the AVPlayer state through the **state** attribute or obtain the reported AVPlayer state by subscribing to the [stateChange](#stateChange_on) event. For details about the rules for state transition, see [AVPlayer Development](../../media/avplayer-playback.md). Enumerates the states of the [AVPlayer](#avplayer9). Your application can proactively obtain the AVPlayer state through the **state** attribute or obtain the reported AVPlayer state by subscribing to the [stateChange](#stateChange_on) event. For details about the rules for state transition, see [Audio Playback](../../media/using-avplayer-for-playback.md).
**System capability**: SystemCapability.Multimedia.Media.AVPlayer **System capability**: SystemCapability.Multimedia.Media.AVPlayer
...@@ -1710,7 +1710,11 @@ audioPlayer.getTrackDescription((error, arrList) => { ...@@ -1710,7 +1710,11 @@ audioPlayer.getTrackDescription((error, arrList) => {
A recording management class that provides APIs to record media assets. Before calling any API in **AVRecorder**, you must use **createAVRecorder()** to create an **AVRecorder** instance. A recording management class that provides APIs to record media assets. Before calling any API in **AVRecorder**, you must use **createAVRecorder()** to create an **AVRecorder** instance.
For details about the AVRecorder demo, see [AVRecorder Development](../../media/avrecorder.md). For details about the audio and video recording demo, see [Audio Recording](../../media/using-avrecorder-for-recording.md) and [Video Recording](../../media/video-recording.md).
> **NOTE**
>
> To use the camera to record videos, the camera module is required. For details about how to use the APIs provided by the camera module, see [Camera Management](js-apis-camera.md).
### Attributes ### Attributes
...@@ -1763,7 +1767,7 @@ let AVRecorderProfile = { ...@@ -1763,7 +1767,7 @@ let AVRecorderProfile = {
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : media.CodecMimeType.VIDEO_MPEG4, videoCodec : media.CodecMimeType.VIDEO_AVC,
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
...@@ -1834,7 +1838,7 @@ let AVRecorderProfile = { ...@@ -1834,7 +1838,7 @@ let AVRecorderProfile = {
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : media.CodecMimeType.VIDEO_MPEG4, videoCodec : media.CodecMimeType.VIDEO_AVC,
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
...@@ -2536,7 +2540,7 @@ Describes the audio and video recording profile. ...@@ -2536,7 +2540,7 @@ Describes the audio and video recording profile.
| audioSampleRate | number | No | Audio sampling rate. This parameter is mandatory for audio recording. | | audioSampleRate | number | No | Audio sampling rate. This parameter is mandatory for audio recording. |
| fileFormat | [ContainerFormatType](#containerformattype8) | Yes | Container format of a file. This parameter is mandatory. | | fileFormat | [ContainerFormatType](#containerformattype8) | Yes | Container format of a file. This parameter is mandatory. |
| videoBitrate | number | No | Video encoding bit rate. This parameter is mandatory for video recording. | | videoBitrate | number | No | Video encoding bit rate. This parameter is mandatory for video recording. |
| videoCodec | [CodecMimeType](#codecmimetype8) | No | Video encoding format. This parameter is mandatory for video recording. Only **VIDEO_AVC** and **VIDEO_MPEG4** are supported.| | videoCodec | [CodecMimeType](#codecmimetype8) | No | Video encoding format. This parameter is mandatory for video recording. You need to query the encoding capabilities (including the encoding format and resolution) supported by the device.|
| videoFrameWidth | number | No | Width of a video frame. This parameter is mandatory for video recording. | | videoFrameWidth | number | No | Width of a video frame. This parameter is mandatory for video recording. |
| videoFrameHeight | number | No | Height of a video frame. This parameter is mandatory for video recording. | | videoFrameHeight | number | No | Height of a video frame. This parameter is mandatory for video recording. |
| videoFrameRate | number | No | Video frame rate. This parameter is mandatory for video recording. | | videoFrameRate | number | No | Video frame rate. This parameter is mandatory for video recording. |
...@@ -2593,8 +2597,6 @@ Describes the geographical location of the recorded video. ...@@ -2593,8 +2597,6 @@ Describes the geographical location of the recorded video.
Implements video recording. Before calling any API in the **VideoRecorder** class, you must use [createVideoRecorder()](#mediacreatevideorecorder9) to create a [VideoRecorder](#videorecorder9) instance. Implements video recording. Before calling any API in the **VideoRecorder** class, you must use [createVideoRecorder()](#mediacreatevideorecorder9) to create a [VideoRecorder](#videorecorder9) instance.
For details about the video recording demo, see [Video Recording Development](../../media/video-recorder.md).
### Attributes ### Attributes
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder **System capability**: SystemCapability.Multimedia.Media.VideoRecorder
...@@ -2646,7 +2648,7 @@ let videoProfile = { ...@@ -2646,7 +2648,7 @@ let videoProfile = {
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : 'mp4', fileFormat : 'mp4',
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : 'video/mp4v-es', videoCodec : 'video/avc',
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
...@@ -2717,7 +2719,7 @@ let videoProfile = { ...@@ -2717,7 +2719,7 @@ let videoProfile = {
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : 'mp4', fileFormat : 'mp4',
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : 'video/mp4v-es', videoCodec : 'video/avc',
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
...@@ -3795,7 +3797,7 @@ Subscribes to the audio playback events. ...@@ -3795,7 +3797,7 @@ Subscribes to the audio playback events.
**Example** **Example**
```js ```js
import fileio from '@ohos.fileio' import fs from '@ohos.file.fs';
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully.
...@@ -3839,15 +3841,15 @@ audioPlayer.on('error', (error) => { // Set the 'error' event callback ...@@ -3839,15 +3841,15 @@ audioPlayer.on('error', (error) => { // Set the 'error' event callback
let fdPath = 'fd://'; let fdPath = 'fd://';
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command. // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command.
let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3';
fileio.open(path).then((fdValue) => { fs.open(path).then((file) => {
fdPath = fdPath + '' + fdValue; fdPath = fdPath + '' + file.fd;
console.info('open fd success fd is' + fdPath); console.info('open fd success fd is' + fdPath);
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
}, (err) => { }, (err) => {
console.info('open fd failed err is' + err); console.info('open fd failed err is' + err);
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + err); console.info('open fd failed err is' + err);
}); });
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
``` ```
### on('timeUpdate') ### on('timeUpdate')
...@@ -3928,8 +3930,6 @@ Enumerates the audio playback states. You can obtain the state through the **sta ...@@ -3928,8 +3930,6 @@ Enumerates the audio playback states. You can obtain the state through the **sta
Provides APIs to manage and play video. Before calling any API of **VideoPlayer**, you must use [createVideoPlayer()](#createvideoplayer) to create a **VideoPlayer** instance. Provides APIs to manage and play video. Before calling any API of **VideoPlayer**, you must use [createVideoPlayer()](#createvideoplayer) to create a **VideoPlayer** instance.
For details about the video playback demo, see [Video Playback Development](../../media/video-playback.md).
### Attributes<a name=videoplayer_attributes></a> ### Attributes<a name=videoplayer_attributes></a>
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer **System capability**: SystemCapability.Multimedia.Media.VideoPlayer
...@@ -4750,8 +4750,6 @@ Enumerates the video playback states. You can obtain the state through the **sta ...@@ -4750,8 +4750,6 @@ Enumerates the video playback states. You can obtain the state through the **sta
Implements audio recording. Before calling any API of **AudioRecorder**, you must use [createAudioRecorder()](#mediacreateaudiorecorder) to create an **AudioRecorder** instance. Implements audio recording. Before calling any API of **AudioRecorder**, you must use [createAudioRecorder()](#mediacreateaudiorecorder) to create an **AudioRecorder** instance.
For details about the audio recording demo, see [Audio Recording Development](../../media/audio-recorder.md).
### prepare<a name=audiorecorder_prepare></a> ### prepare<a name=audiorecorder_prepare></a>
prepare(config: AudioRecorderConfig): void prepare(config: AudioRecorderConfig): void
......
...@@ -144,7 +144,7 @@ Describes the injected simulated mouse button. ...@@ -144,7 +144,7 @@ Describes the injected simulated mouse button.
## On<sup>9+</sup> ## On<sup>9+</sup>
Since API version 9, the UiTest framework provides a wide range of UI component feature description APIs in the **On** class to filter and match components. Since API version 9, the UiTest framework provides a wide range of UI component feature description APIs in the **On** class to filter and match components.
The API capabilities provided by the **On** class exhibit the following features: 1. Allow one or more attributes as the match conditions. For example, you can specify both the **text** and **id** attributes to find the target component. <br>2. Provide multiple match patterns for component attributes. <br>3. Support absolute positioning and relative positioning for components. APIs such as [ON.isBefore](#isbefore) and [ON.isAfter](#isafter) can be used to specify the features of adjacent components to assist positioning. <br>All APIs provided in the **On** class are synchronous. You are advised to use the static constructor **ON** to create an **On** object in chain mode. The API capabilities provided by the **On** class exhibit the following features: 1. Allow one or more attributes as the match conditions. For example, you can specify both the **text** and **id** attributes to find the target component. <br>2. Provide multiple match patterns for component attributes. <br>3. Support absolute positioning and relative positioning for components. APIs such as [ON.isBefore](#isbefore9) and [ON.isAfter](#isafter9) can be used to specify the features of adjacent components to assist positioning. <br>All APIs provided in the **On** class are synchronous. You are advised to use the static constructor **ON** to create an **On** object in chain mode.
```js ```js
ON.text('123').type('button'); ON.text('123').type('button');
...@@ -542,7 +542,7 @@ Specifies that the target component is within the given application window. ...@@ -542,7 +542,7 @@ Specifies that the target component is within the given application window.
**Example** **Example**
```js ```js
let on = ON.inWindow(ON.inWindow('com.uitestScene.acts')); // Create an On object using the static constructor ON, specifying that the target component is within the given application window. let on = ON.inWindow('com.uitestScene.acts'); // Create an On object using the static constructor ON, specifying that the target component is within the given application window.
``` ```
## Component<sup>9+</sup> ## Component<sup>9+</sup>
...@@ -1553,7 +1553,7 @@ Searches this **Driver** object for the target component that matches the given ...@@ -1553,7 +1553,7 @@ Searches this **Driver** object for the target component that matches the given
| Type | Description | | Type | Description |
| --------------------------------- | --------------------------------- | | --------------------------------- | --------------------------------- |
| Promise\<[Component](#component)> | Promise used to return the found component.| | Promise\<[Component](#component9)> | Promise used to return the found component.|
**Error codes** **Error codes**
......
...@@ -234,7 +234,7 @@ Sends a message. For the complete sample code, see [onMessageEventExt](#onmessag ...@@ -234,7 +234,7 @@ Sends a message. For the complete sample code, see [onMessageEventExt](#onmessag
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | :------------- | | ------- | ------ | ---- | :------------- |
| message | [WebMessageExt](#webmessageext) | Yes | Message to send.| | message | [WebMessageExt](#webmessageext10) | Yes | Message to send.|
**Error codes** **Error codes**
...@@ -491,7 +491,7 @@ Sets how the \<Web> component uses HTTPDNS for DNS resolution. ...@@ -491,7 +491,7 @@ Sets how the \<Web> component uses HTTPDNS for DNS resolution.
| Name | Type | Mandatory | Description| | Name | Type | Mandatory | Description|
| ------------------ | ------- | ---- | ------------- | | ------------------ | ------- | ---- | ------------- |
| secureDnsMode | [SecureDnsMode](#securednsmode) | Yes | Mode in which HTTPDNS is used.| | secureDnsMode | [SecureDnsMode](#securednsmode10) | Yes | Mode in which HTTPDNS is used.|
| secureDnsConfig | string | Yes| Information about the HTTPDNS server to use, which must use HTTPS. Only one HTTPDNS server can be configured.| | secureDnsConfig | string | Yes| Information about the HTTPDNS server to use, which must use HTTPS. Only one HTTPDNS server can be configured.|
**Example** **Example**
...@@ -504,7 +504,6 @@ import web_webview from '@ohos.web.webview'; ...@@ -504,7 +504,6 @@ import web_webview from '@ohos.web.webview';
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log("EntryAbility onCreate") console.log("EntryAbility onCreate")
web_webview.WebviewController.initializeWebEngine()
try { try {
web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.Auto, "https://example1.test") web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.Auto, "https://example1.test")
} catch(error) { } catch(error) {
...@@ -1420,7 +1419,7 @@ Executes a JavaScript script. This API uses a promise to return the script execu ...@@ -1420,7 +1419,7 @@ Executes a JavaScript script. This API uses a promise to return the script execu
| Type | Description | | Type | Description |
| --------------- | --------------------------------------------------- | | --------------- | --------------------------------------------------- |
| Promise\<string> | Promise used to return the result. Returns **null** if the JavaScript script fails to be executed| | Promise\<string> | Promise used to return the result if the operation is successful and null otherwise.|
**Error codes** **Error codes**
...@@ -2637,7 +2636,7 @@ Stores this web page. This API uses an asynchronous callback to return the resul ...@@ -2637,7 +2636,7 @@ Stores this web page. This API uses an asynchronous callback to return the resul
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------- | ---- | ------------------------------------------------------------ |
| baseName | string | Yes | Save path. The value cannot be null. | | baseName | string | Yes | Save path. The value cannot be null. |
| autoName | boolean | Yes | Whether to automatically generate a file name. The value **false** means not to automatically generate a file name. The value **true** means to automatically generate a file name based on the URL of current page and the **baseName** value. In this case, **baseName** is regarded as a directory.| | autoName | boolean | Yes | Whether to automatically generate a file name. The value **false** means not to automatically generate a file name. The value **true** means to automatically generate a file name based on the URL of the current page and the **baseName** value. In this case, **baseName** is regarded as a directory.|
| callback | AsyncCallback\<string> | Yes | Callback used to return the save path if the operation is successful and null otherwise. | | callback | AsyncCallback\<string> | Yes | Callback used to return the save path if the operation is successful and null otherwise. |
**Error codes** **Error codes**
...@@ -2662,7 +2661,7 @@ struct WebComponent { ...@@ -2662,7 +2661,7 @@ struct WebComponent {
build() { build() {
Column() { Column() {
Button('saveWebArchive') Button('storeWebArchive')
.onClick(() => { .onClick(() => {
try { try {
this.controller.storeWebArchive("/data/storage/el2/base/", true, (error, filename) => { this.controller.storeWebArchive("/data/storage/el2/base/", true, (error, filename) => {
...@@ -2697,7 +2696,7 @@ Stores this web page. This API uses a promise to return the result. ...@@ -2697,7 +2696,7 @@ Stores this web page. This API uses a promise to return the result.
| Name | Type| Mandatory| Description | | Name | Type| Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ | | -------- | -------- | ---- | ------------------------------------------------------------ |
| baseName | string | Yes | Save path. The value cannot be null. | | baseName | string | Yes | Save path. The value cannot be null. |
| autoName | boolean | Yes | Whether to automatically generate a file name. The value **false** means not to automatically generate a file name. The value **true** means to automatically generate a file name based on the URL of current page and the **baseName** value. In this case, **baseName** is regarded as a directory.| | autoName | boolean | Yes | Whether to automatically generate a file name. The value **false** means not to automatically generate a file name. The value **true** means to automatically generate a file name based on the URL of the current page and the **baseName** value. In this case, **baseName** is regarded as a directory.|
**Return value** **Return value**
...@@ -2727,7 +2726,7 @@ struct WebComponent { ...@@ -2727,7 +2726,7 @@ struct WebComponent {
build() { build() {
Column() { Column() {
Button('saveWebArchive') Button('storeWebArchive')
.onClick(() => { .onClick(() => {
try { try {
this.controller.storeWebArchive("/data/storage/el2/base/", true) this.controller.storeWebArchive("/data/storage/el2/base/", true)
...@@ -2848,6 +2847,8 @@ backOrForward(step: number): void ...@@ -2848,6 +2847,8 @@ backOrForward(step: number): void
Performs a specific number of steps forward or backward on the current page based on the history stack. No redirection will be performed if the corresponding page does not exist in the history stack. Performs a specific number of steps forward or backward on the current page based on the history stack. No redirection will be performed if the corresponding page does not exist in the history stack.
Because the previously loaded web pages are used for the operation, no page reloading is involved.
**System capability**: SystemCapability.Web.Webview.Core **System capability**: SystemCapability.Web.Webview.Core
**Parameters** **Parameters**
...@@ -3586,10 +3587,11 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error ...@@ -3586,10 +3587,11 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
**Example** **Example**
1. To perform operations on files, you must import the file management module. For details, see [File Management](./js-apis-file-fs.md).
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview'; import web_webview from '@ohos.web.webview';
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
@Entry @Entry
@Component @Component
...@@ -3602,11 +3604,13 @@ struct WebComponent { ...@@ -3602,11 +3604,13 @@ struct WebComponent {
.onClick(() => { .onClick(() => {
try { try {
let state = this.controller.serializeWebState(); let state = this.controller.serializeWebState();
let path = globalThis.AbilityContext.cacheDir; // Obtain the value of globalThis.cacheDir from MainAbility.ts.
let path = globalThis.cacheDir;
path += '/WebState'; path += '/WebState';
let fd = fileio.openSync(path, 0o2 | 0o100, 0o666); // Synchronously open a file.
fileio.writeSync(fd, state.buffer); let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
fileio.closeSync(fd); fs.writeSync(file.fd, state.buffer);
fs.closeSync(file.fd);
} catch (error) { } catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
} }
...@@ -3617,6 +3621,21 @@ struct WebComponent { ...@@ -3617,6 +3621,21 @@ struct WebComponent {
} }
``` ```
2. Modify **MainAbility.ts**.
Obtain the path of the application cache file.
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
import web_webview from '@ohos.web.webview';
export default class MainAbility extends UIAbility {
onCreate(want, launchParam) {
// Bind cacheDir to the globalThis object to implement data synchronization between the UIAbility component and the page.
globalThis.cacheDir = this.context.cacheDir;
}
}
```
### restoreWebState ### restoreWebState
restoreWebState(state: Uint8Array): void restoreWebState(state: Uint8Array): void
...@@ -3641,10 +3660,11 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error ...@@ -3641,10 +3660,11 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
**Example** **Example**
1. To perform operations on files, you must import the file management module. For details, see [File Management](./js-apis-file-fs.md).
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview'; import web_webview from '@ohos.web.webview';
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
@Entry @Entry
@Component @Component
...@@ -3656,17 +3676,22 @@ struct WebComponent { ...@@ -3656,17 +3676,22 @@ struct WebComponent {
Button('RestoreWebState') Button('RestoreWebState')
.onClick(() => { .onClick(() => {
try { try {
let path = globalThis.AbilityContext.cacheDir; // Obtain the value of globalThis.cacheDir from MainAbility.ts.
let path = globalThis.cacheDir;
path += '/WebState'; path += '/WebState';
let fd = fileio.openSync(path, 0o002, 0o666); // Synchronously open a file.
let stat = fileio.fstatSync(fd); let file = fs.openSync(path, fs.OpenMode.READ_WRITE);
let stat = fs.statSync(path);
let size = stat.size; let size = stat.size;
let buf = new ArrayBuffer(size); let buf = new ArrayBuffer(size);
fileio.read(fd, buf, (err, data) => { fs.read(file.fd, buf, (err, readLen) => {
if (data) { if (err) {
this.controller.restoreWebState(new Uint8Array(data.buffer)); console.info("mkdir failed with error message: " + err.message + ", error code: " + err.code);
} else {
console.info("read file data succeed");
this.controller.restoreWebState(new Uint8Array(buf.slice(0, readLen)));
fs.closeSync(file);
} }
fileio.closeSync(fd);
}); });
} catch (error) { } catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
...@@ -3678,6 +3703,21 @@ struct WebComponent { ...@@ -3678,6 +3703,21 @@ struct WebComponent {
} }
``` ```
2. Modify **MainAbility.ts**.
Obtain the path of the application cache file.
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
import web_webview from '@ohos.web.webview';
export default class MainAbility extends UIAbility {
onCreate(want, launchParam) {
// Bind cacheDir to the globalThis object to implement data synchronization between the UIAbility component and the page.
globalThis.cacheDir = this.context.cacheDir;
}
}
```
### customizeSchemes ### customizeSchemes
static customizeSchemes(schemes: Array\<WebCustomScheme\>): void static customizeSchemes(schemes: Array\<WebCustomScheme\>): void
......
...@@ -25,7 +25,7 @@ Zips a file. This API uses a promise to return the result. ...@@ -25,7 +25,7 @@ Zips a file. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the folder or file to zip. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the folder or file to zip. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. | | outFile | string | Yes | Path of the zipped file. The file name extension is .zip. |
| options | [Options](#options) | Yes | Optional parameters for the zip operation. | | options | [Options](#options) | Yes | Optional parameters for the zip operation. |
...@@ -50,9 +50,9 @@ let options = { ...@@ -50,9 +50,9 @@ let options = {
}; };
zlib.zipFile(inFile, outFile, options).then((data) => { zlib.zipFile(inFile, outFile, options).then((data) => {
console.log('zipFile result is ' + JSON.Stringify(data)); console.log('zipFile result is ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log('error is ' + JSON.Stringify(err)); console.log('error is ' + JSON.stringify(err));
}); });
``` ```
...@@ -71,9 +71,9 @@ let options = { ...@@ -71,9 +71,9 @@ let options = {
}; };
zlib.zipFile(inFile , outFile, options).then((data) => { zlib.zipFile(inFile , outFile, options).then((data) => {
console.log('zipFile result is ' + JSON.Stringify(data)); console.log('zipFile result is ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.log('error is ' + JSON.Stringify(err)); console.log('error is ' + JSON.stringify(err));
}); });
``` ```
...@@ -91,7 +91,7 @@ Unzips a file. This API uses a promise to return the result. ...@@ -91,7 +91,7 @@ Unzips a file. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the file to unzip. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the file to unzip. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the unzipped file. | | outFile | string | Yes | Path of the unzipped file. |
| options | [Options](#options) | Yes | Optional parameters for the unzip operation. | | options | [Options](#options) | Yes | Optional parameters for the unzip operation. |
...@@ -116,9 +116,9 @@ let options = { ...@@ -116,9 +116,9 @@ let options = {
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
}; };
zlib.unzipFile(inFile, outFile, options).then((data) => { zlib.unzipFile(inFile, outFile, options).then((data) => {
console.log('unzipFile result is ' + JSON.Stringify(data)); console.log('unzipFile result is ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.log('error is ' + JSON.Stringify(err)); console.log('error is ' + JSON.stringify(err));
}) })
``` ```
...@@ -134,7 +134,7 @@ Compresses a file. This API uses an asynchronous callback to return the result. ...@@ -134,7 +134,7 @@ Compresses a file. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | | ----------------------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the folder or file to compress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the folder or file to compress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the compressed file. | | outFile | string | Yes | Path of the compressed file. |
| options | [Options](#options) | Yes | Compression parameters. | | options | [Options](#options) | Yes | Compression parameters. |
| AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. | | AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. |
...@@ -172,6 +172,8 @@ try { ...@@ -172,6 +172,8 @@ try {
} }
``` ```
## zlib.compressFile<sup>9+</sup>
compressFile(inFile: string, outFile: string, options: Options): Promise\<void>; compressFile(inFile: string, outFile: string, options: Options): Promise\<void>;
Compresses a file. This API uses a promise to return the result. Compresses a file. This API uses a promise to return the result.
...@@ -182,7 +184,7 @@ Compresses a file. This API uses a promise to return the result. ...@@ -182,7 +184,7 @@ Compresses a file. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the folder or file to compress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the folder or file to compress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the compressed file. | | outFile | string | Yes | Path of the compressed file. |
| options | [Options](#options) | Yes | Compression parameters. | | options | [Options](#options) | Yes | Compression parameters. |
...@@ -232,8 +234,8 @@ Decompresses a file. This API uses an asynchronous callback to return the result ...@@ -232,8 +234,8 @@ Decompresses a file. This API uses an asynchronous callback to return the result
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | | ----------------------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. | | outFile | string | Yes | Path of the decompressed file. The path must exist in the system. Otherwise, the decompression fails. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| options | [Options](#options) | Yes | Decompression parameters. | | options | [Options](#options) | Yes | Decompression parameters. |
| AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. | | AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. |
...@@ -253,7 +255,7 @@ For details about the error codes, see [zlib Error Codes](../errorcodes/errorcod ...@@ -253,7 +255,7 @@ For details about the error codes, see [zlib Error Codes](../errorcodes/errorcod
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through the context. // The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through the context.
import zlib from '@ohos.zlib'; import zlib from '@ohos.zlib';
let inFile = '/xx/xxx.zip'; let inFile = '/xx/xxx.zip';
let outFile = '/xxx'; let outFileDir = '/xxx';
let options = { let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
...@@ -261,7 +263,7 @@ let options = { ...@@ -261,7 +263,7 @@ let options = {
}; };
try { try {
zlib.decompressFile(inFile, outFile, options, (errData) => { zlib.decompressFile(inFile, outFileDir, options, (errData) => {
if (errData !== null) { if (errData !== null) {
console.log(`errData is errCode:${errData.code} message:${errData.message}`); console.log(`errData is errCode:${errData.code} message:${errData.message}`);
} }
...@@ -271,6 +273,8 @@ try { ...@@ -271,6 +273,8 @@ try {
} }
``` ```
## zlib.decompressFile<sup>9+</sup>
decompressFile(inFile: string, outFile: string, options: Options): Promise\<void>; decompressFile(inFile: string, outFile: string, options: Options): Promise\<void>;
Decompresses a file. This API uses a promise to return the result. Decompresses a file. This API uses a promise to return the result.
...@@ -281,8 +285,8 @@ Decompresses a file. This API uses a promise to return the result. ...@@ -281,8 +285,8 @@ Decompresses a file. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. | | outFile | string | Yes | Path of the decompressed file. The path must exist in the system. Otherwise, the decompression fails. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| options | [Options](#options) | Yes | Decompression parameters. | | options | [Options](#options) | Yes | Decompression parameters. |
**Error codes** **Error codes**
...@@ -299,7 +303,7 @@ For details about the error codes, see [zlib Error Codes](../errorcodes/errorcod ...@@ -299,7 +303,7 @@ For details about the error codes, see [zlib Error Codes](../errorcodes/errorcod
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through the context. // The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through the context.
import zlib from '@ohos.zlib'; import zlib from '@ohos.zlib';
let inFile = '/xx/xxx.zip'; let inFile = '/xx/xxx.zip';
let outFile = '/xxx'; let outFileDir = '/xxx';
let options = { let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
...@@ -307,7 +311,7 @@ let options = { ...@@ -307,7 +311,7 @@ let options = {
}; };
try { try {
zlib.decompressFile(inFile, outFile, options).then((data) => { zlib.decompressFile(inFile, outFileDir, options).then((data) => {
console.info('decompressFile success'); console.info('decompressFile success');
}).catch((errData) => { }).catch((errData) => {
console.log(`errData is errCode:${errData.code} message:${errData.message}`); console.log(`errData is errCode:${errData.code} message:${errData.message}`);
......
...@@ -22,7 +22,7 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -22,7 +22,7 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| min | number \| string | No| Minimum size of the **\<Blank>** component in the container along the main axis.<br>Default value: **0**| | min | number \| string | No| Minimum size of the **\<Blank>** component in the container along the main axis.<br>Default value: **0**<br>**NOTE**<br>This parameter cannot be set in percentage. If the value is negative, the default value is used. If the minimum size is larger than the available space of the container, it is used as the component size, and the component extends beyond the container.|
## Attributes ## Attributes
...@@ -30,10 +30,14 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -30,10 +30,14 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| color | [ResourceColor](ts-types.md#resourcecolor) | Color to fill the empty spaces.<br>Since API version 9, this API is supported in ArkTS widgets.| | color | [ResourceColor](ts-types.md#resourcecolor) | Color to fill the empty spaces.<br>Default value: **Color.Transparent**<br>Since API version 9, this API is supported in ArkTS widgets. |
## Events
The [universal events](ts-universal-events-click.md) are supported.
## Example ## Example
### Example 1 ### Example 1
The sample below shows how the **\<Blank>** component fills the empty spaces in the container in landscape and portrait modes. The sample below shows how the **\<Blank>** component fills the empty spaces in the container in landscape and portrait modes.
```ts ```ts
......
...@@ -25,8 +25,8 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -25,8 +25,8 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Name | Type | Description | | Name | Type | Description |
| ----------- | ---------- | ------------------ | | ----------- | ---------- | ------------------ |
| vertical | boolean | Whether a vertical divider is used. **false**: A horizontal divider is used.<br>**true**: A vertical divider is used.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.| | vertical | boolean | Whether a vertical divider is used. **false**: A horizontal divider is used.<br>**true**: A vertical divider is used.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.|
| color | [ResourceColor](ts-types.md#resourcecolor) | Color of the divider.<br>Since API version 9, this API is supported in ArkTS widgets.| | color | [ResourceColor](ts-types.md#resourcecolor) | Color of the divider.<br>Default value: **'\#33182431'**<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeWidth | number \| string | Width of the divider.<br>Default value: **1**<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute cannot be set to a percentage.| | strokeWidth | number \| string | Width of the divider.<br>Default value: **1**<br>Unit: vp<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute cannot be set to a percentage. The priority of this attribute is lower than that of the universal attribute [height](ts-universal-attributes-size.md). If the value of this attribute is greater than that of the universal attribute, cropping is performed based on the universal attribute settings.|
| lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the divider.<br>Default value: **LineCapStyle.Butt**<br>Since API version 9, this API is supported in ArkTS widgets.| | lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the divider.<br>Default value: **LineCapStyle.Butt**<br>Since API version 9, this API is supported in ArkTS widgets.|
......
...@@ -9,7 +9,10 @@ ...@@ -9,7 +9,10 @@
## Child Components ## Child Components
Supported > **NOTE**
>
> - Supported types of child components: built-in components and custom components, with support for ([if/else](../../quick-start/arkts-rendering-control-ifelse.md), [ForEach](../../quick-start/arkts-rendering-control-foreach.md), and [LazyForEach](../../quick-start/arkts-rendering-control-lazyforeach.md)) rendering control.
> - Number of child components: multiple.
## APIs ## APIs
...@@ -22,6 +25,10 @@ NavDestination() ...@@ -22,6 +25,10 @@ NavDestination()
In addition to the [backgroundColor](ts-universal-attributes-background.md) attribute, the following attributes are supported. In addition to the [backgroundColor](ts-universal-attributes-background.md) attribute, the following attributes are supported.
| Name | Type | Description | | Name | Type | Description |
| -------------- | ---------------------------------------- | ---------------------------------------- | | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| title | string \| [CustomBuilder](ts-types.md#custombuilder8) \| [NavigationCommonTitle](ts-basic-components-navigation.md#navigationcommontitle) \| [NavigationCustomTitle](ts-basic-components-navigation.md##navigationcustomtitle) | Page title. | | title | string \| [CustomBuilder](ts-types.md#custombuilder8) \| [NavigationCommonTitle](ts-basic-components-navigation.md#navigationcommontitle) \| [NavigationCustomTitle](ts-basic-components-navigation.md##navigationcustomtitle) | Page title.<br>**NOTE**<br>When the NavigationCustomTitle type is used to set the height, the **titleMode** attribute does not take effect.<br>When the title string is too long: (1) If no subtitle is set, the string is scaled down, wrapped in two lines, and then clipped with an ellipsis (...); (2) If a subtitle is set, the subtitle is scaled down and then clipped with an ellipsis (...).|
| hideTitleBar | boolean | Whether to hide the title bar.<br>Default value: **false**<br>**true**: Hide the title bar.<br>**false**: Display the title bar.| | hideTitleBar | boolean | Whether to hide the title bar.<br>Default value: **false**<br>**true**: Hide the title bar.<br>**false**: Display the title bar.|
## Events
The [universal events](ts-universal-events-click.md) are supported.
...@@ -31,9 +31,16 @@ Creates a **PluginComponent** to display the UI provided by an external applicat ...@@ -31,9 +31,16 @@ Creates a **PluginComponent** to display the UI provided by an external applicat
| source | string | Component template name. | | source | string | Component template name. |
| bundleName | string | Bundle name of the provider ability.| | bundleName | string | Bundle name of the provider ability.|
## Attributes
The universal attribute [size](ts-universal-attributes-size.md) is supported and must be set.
## Events ## Events
Only the [gesture event](ts-gesture-settings.md) can be distributed to the provider page and processed inside the provider page.
In addition to the [universal events](ts-universal-events-click.md), the following events are supported.
| Name | Description | | Name | Description |
| ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| onComplete(callback: () =&gt; void) | Triggered when the component loading is complete. | | onComplete(callback: () =&gt; void) | Triggered when the component loading is complete. |
......
...@@ -55,13 +55,18 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -55,13 +55,18 @@ Since API version 9, this API is supported in ArkTS widgets.
## Attributes ## Attributes
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| value | number | Current progress. If the value is less than 0, the value **0** is used. If the value is greater than that of **total**, the value of **total** is used. Invalid values do not take effect.<br>Since API version 9, this API is supported in ArkTS widgets.| | value | number | Current progress. If the value is less than 0, the value **0** is used. If the value is greater than that of **total**, the value of **total** is used. Invalid values do not take effect.<br>Since API version 9, this API is supported in ArkTS widgets.|
| color | [ResourceColor](ts-types.md#resourcecolor) | Background color of the progress indicator.<br>Since API version 9, this API is supported in ArkTS widgets.| | color | [ResourceColor](ts-types.md#resourcecolor) | Background color of the progress indicator.<br>Default value: **'\#ff007dff'**<br>Since API version 9, this API is supported in ArkTS widgets.|
| backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the progress indicator.<br>Since API version 9, this API is supported in ArkTS widgets.| | backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the progress indicator.<br>Default value: **'\#19182431'**<br><br>Since API version 9, this API is supported in ArkTS widgets.|
| style<sup>8+</sup> | {<br>strokeWidth?: [Length](ts-types.md#length),<br>scaleCount?: number,<br>scaleWidth?: [Length](ts-types.md#length)<br>} | Component style.<br>- **strokeWidth**: stroke width of the progress indicator. It cannot be set in percentage. Since API version 9, if the stroke width of the ring progress bar is greater than or equal to the radius, the width is changed to half of the radius.<br>Default value: **4.0Vp**<br>- **scaleCount**: number of divisions on the determinate ring-type process indicator.<br>Default value: **120**<br>- **scaleWidth**: scale width of the ring progress bar. It cannot be set in percentage. If it is greater than the value of **strokeWidth**, the default scale width is used.<br>Default value: **2.0Vp**<br>Since API version 9, this API is supported in ArkTS widgets.| | style<sup>8+</sup> | {<br>strokeWidth?: [Length](ts-types.md#length),<br>scaleCount?: number,<br>scaleWidth?: [Length](ts-types.md#length)<br>} | Component style.<br>- **strokeWidth**: stroke width of the progress indicator. It cannot be set in percentage. Since API version 9, if the stroke width of the ring progress bar is greater than or equal to the radius, the width is changed to half of the radius.<br>Default value: **4.0Vp**<br>- **scaleCount**: number of divisions on the determinate ring-type process indicator.<br>Default value: **120**<br>- **scaleWidth**: scale width of the ring progress bar. It cannot be set in percentage. If it is greater than the value of **strokeWidth**, the default scale width is used.<br>Default value: **2.0Vp**<br>Since API version 9, this API is supported in ArkTS widgets.|
## Events
The [universal events](ts-universal-events-click.md) are supported.
## Example ## Example
......
...@@ -537,7 +537,7 @@ multiWindowAccess(multiWindow: boolean) ...@@ -537,7 +537,7 @@ multiWindowAccess(multiWindow: boolean)
Sets whether to enable the multi-window permission. Sets whether to enable the multi-window permission.
Enabling the multi-window permission requires implementation of the **onWindowNew** event. For details about the sample code, see [onWindowNew](#onwindownew9). Enabling the multi-window permission requires implementation of the **onWindowNew** event. For the sample code, see [onWindowNew](#onwindownew9).
**Parameters** **Parameters**
...@@ -703,6 +703,40 @@ Sets the cache mode. ...@@ -703,6 +703,40 @@ Sets the cache mode.
} }
``` ```
### textZoomAtio<sup>(deprecated)</sup>
textZoomAtio(textZoomAtio: number)
Sets the text zoom ratio of the page. The default value is **100**, which indicates 100%.
This API is deprecated since API version 9. You are advised to use [textZoomRatio<sup>9+</sup>](#textzoomratio9) instead.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------------- | ------ | ---- | ---- | --------------- |
| textZoomAtio | number | Yes | 100 | Text zoom ratio to set.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
@State atio: number = 150
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.textZoomAtio(this.atio)
}
}
}
```
### textZoomRatio<sup>9+</sup> ### textZoomRatio<sup>9+</sup>
textZoomRatio(textZoomRatio: number) textZoomRatio(textZoomRatio: number)
...@@ -1937,7 +1971,7 @@ Called when loading of the web page is complete. This API is used by an applicat ...@@ -1937,7 +1971,7 @@ Called when loading of the web page is complete. This API is used by an applicat
| Name | Type | Description | | Name | Type | Description |
| ----------- | ------- | ---------------------------------------- | | ----------- | ------- | ---------------------------------------- |
| url | string | URL to be accessed. | | url | string | URL to be accessed. |
| isRefreshed | boolean | Whether the page is reloaded. The value **true** means that the page is reloaded by invoking the [refresh](#refresh) API, and **false** means the opposite.| | isRefreshed | boolean | Whether the page is reloaded. The value **true** means that the page is reloaded by invoking the [refresh<sup>9+</sup>](../apis/js-apis-webview.md#refresh) API, and **false** means the opposite.|
**Example** **Example**
...@@ -3099,7 +3133,7 @@ Called when this web page receives a new favicon. ...@@ -3099,7 +3133,7 @@ Called when this web page receives a new favicon.
Column() { Column() {
Web({ src:'www.example.com', controller: this.controller }) Web({ src:'www.example.com', controller: this.controller })
.onFaviconReceived((event) => { .onFaviconReceived((event) => {
console.log('onFaviconReceived:' + JSON.stringify(event)) console.log('onFaviconReceived');
this.icon = event.favicon; this.icon = event.favicon;
}) })
} }
...@@ -3221,6 +3255,34 @@ Called when the **\<Web>** component is about to access a URL. This API is used ...@@ -3221,6 +3255,34 @@ Called when the **\<Web>** component is about to access a URL. This API is used
} }
``` ```
### onRequestSelected
onRequestSelected(callback: () => void)
Called when the **\<Web>** component obtains the focus.
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.onRequestSelected(() => {
console.log('onRequestSelected')
})
}
}
}
```
## ConsoleMessage ## ConsoleMessage
Implements the **ConsoleMessage** object. For the sample code, see [onConsole](#onconsole). Implements the **ConsoleMessage** object. For the sample code, see [onConsole](#onconsole).
...@@ -4145,7 +4207,7 @@ Describes the web-based media playback policy. ...@@ -4145,7 +4207,7 @@ Describes the web-based media playback policy.
| Name | Type | Readable| Writable| Mandatory| Description | | Name | Type | Readable| Writable| Mandatory| Description |
| -------------- | --------- | ---- | ---- | --- | ---------------------------- | | -------------- | --------- | ---- | ---- | --- | ---------------------------- |
| resumeInterval | number | Yes | Yes | No |Validity period for automatically resuming a paused web audio, in seconds. The maximum validity period is 60 seconds.| | resumeInterval | number | Yes | Yes | No |Validity period for automatically resuming a paused web audio, in seconds. The maximum validity period is 60 seconds. Due to the approximate value, the validity period may have a deviation of less than 1 second.|
| audioExclusive | boolean | Yes | Yes | No | Whether the audio of multiple **\<Web>** instances in an application is exclusive. | | audioExclusive | boolean | Yes | Yes | No | Whether the audio of multiple **\<Web>** instances in an application is exclusive. |
## DataResubmissionHandler<sup>9+</sup> ## DataResubmissionHandler<sup>9+</sup>
...@@ -4228,7 +4290,7 @@ Obtains the cookie management object of the **\<Web>** component. ...@@ -4228,7 +4290,7 @@ Obtains the cookie management object of the **\<Web>** component.
| Type | Description | | Type | Description |
| --------- | ---------------------------------------- | | --------- | ---------------------------------------- |
| WebCookie | Cookie management object. For details, see [WebCookie](#webcookie).| | WebCookie | Cookie management object. For details, see [WebCookie](#webcookiedeprecated).|
**Example** **Example**
...@@ -4457,7 +4519,7 @@ This API is deprecated since API version 9. You are advised to use [forward<sup> ...@@ -4457,7 +4519,7 @@ This API is deprecated since API version 9. You are advised to use [forward<sup>
deleteJavaScriptRegister(name: string) deleteJavaScriptRegister(name: string)
Deletes a specific application JavaScript object that is registered with the window through **registerJavaScriptProxy**. The deletion takes effect immediately, with no need for invoking the [refresh](#refresh) API. Deletes a specific application JavaScript object that is registered with the window through **registerJavaScriptProxy**. The deletion takes effect immediately, with no need for invoking the[refresh](#refreshdeprecated) API.
This API is deprecated since API version 9. You are advised to use [deleteJavaScriptRegister<sup>9+</sup>](../apis/js-apis-webview.md#deletejavascriptregister). This API is deprecated since API version 9. You are advised to use [deleteJavaScriptRegister<sup>9+</sup>](../apis/js-apis-webview.md#deletejavascriptregister).
...@@ -4738,7 +4800,7 @@ This API is deprecated since API version 9. You are advised to use [refresh<sup> ...@@ -4738,7 +4800,7 @@ This API is deprecated since API version 9. You are advised to use [refresh<sup>
registerJavaScriptProxy(options: { object: object, name: string, methodList: Array\<string\> }) registerJavaScriptProxy(options: { object: object, name: string, methodList: Array\<string\> })
Registers a JavaScript object with the window. APIs of this object can then be invoked in the window. You must invoke the [refresh](#refresh) API for the registration to take effect. Registers a JavaScript object with the window. APIs of this object can then be invoked in the window. You must invoke the [refresh](#refreshdeprecated) API for the registration to take effect.
This API is deprecated since API version 9. You are advised to use [registerJavaScriptProxy<sup>9+</sup>](../apis/js-apis-webview.md#registerjavascriptproxy). This API is deprecated since API version 9. You are advised to use [registerJavaScriptProxy<sup>9+</sup>](../apis/js-apis-webview.md#registerjavascriptproxy).
......
...@@ -4,6 +4,10 @@ SystemCapability (SysCap) is a standalone feature in the OpenHarmony system. ...@@ -4,6 +4,10 @@ SystemCapability (SysCap) is a standalone feature in the OpenHarmony system.
Before using an API for development, you are advised to familiarize yourself with [SysCap](syscap.md), and then consult the following tables to see whether the SysCap set required for the API is supported by the target device type. Before using an API for development, you are advised to familiarize yourself with [SysCap](syscap.md), and then consult the following tables to see whether the SysCap set required for the API is supported by the target device type.
> **NOTE**
>
> The **default** device type represents an OpenHarmony device with comprehensive functions and most common capabilities. When you are not sure about the capability set of the target device, you can use the **default** type for development.
## SystemCapability.ArkUI.ArkUI.Full ## SystemCapability.ArkUI.ArkUI.Full
ArKUI standard system ArKUI standard system
......
...@@ -6,9 +6,9 @@ If an application or a service module running in the background has a service to ...@@ -6,9 +6,9 @@ If an application or a service module running in the background has a service to
## Background Task Types ## Background Task Types
For more targeted management of background applications, OpenHarmony classifies background tasks into the following types and provides an extended resource request mode: For more targeted management of background applications, OpenHarmony classifies background tasks into the following types and provides an extended resource request mode — efficiency resources:
- **No background task**: An application or service module does not need further processing when switched to the background. - **No background task required**: An application or service module does not need further processing when switched to the background.
- **Transient task**: If an application or service module has an urgent, short task that must continue in the background until it is completed, such as data compression, the application or service module can request a transient task for delayed suspension. - **Transient task**: If an application or service module has an urgent, short task that must continue in the background until it is completed, such as data compression, the application or service module can request a transient task for delayed suspension.
...@@ -16,7 +16,7 @@ For more targeted management of background applications, OpenHarmony classifies ...@@ -16,7 +16,7 @@ For more targeted management of background applications, OpenHarmony classifies
- **Work Scheduler task**: The Work Scheduler provides a mechanism for applications to execute non-real-time tasks when the system is idle. If the preset conditions are met, the tasks will be placed in the execution queue and scheduled when the system is idle. - **Work Scheduler task**: The Work Scheduler provides a mechanism for applications to execute non-real-time tasks when the system is idle. If the preset conditions are met, the tasks will be placed in the execution queue and scheduled when the system is idle.
- **Efficiency resources**: If an application needs to ensure that it will not be suspended within a period of time or can normally use certain system resources when it is suspended, it can request efficiency resources, including software and hardware resources. Different types of efficiency resources come with different privileges. For example, the CPU resources enable an application or process to keep running without being suspended, and the WORK_SCHEDULER resources allow for more task execution time before the application or process is suspended. **Efficiency resources**: If an application needs to ensure that it will not be suspended within a period of time or can normally use certain system resources when it is suspended, it can request efficiency resources, including software and hardware resources. Different types of efficiency resources come with different privileges. For example, the CPU resources enable an application or process to keep running without being suspended, and the WORK_SCHEDULER resources allow for more task execution time before the application or process is suspended.
## Selecting a Background Task ## Selecting a Background Task
...@@ -68,7 +68,7 @@ OpenHarmony provides 9 background modes for services that require continuous tas ...@@ -68,7 +68,7 @@ OpenHarmony provides 9 background modes for services that require continuous tas
- If the task is complete, the application should exit the background mode. If the system detects that an application is not using the resources in the corresponding background mode when the application is running in the background, the application is suspended. - If the task is complete, the application should exit the background mode. If the system detects that an application is not using the resources in the corresponding background mode when the application is running in the background, the application is suspended.
- Ensure that the requested continuous task background mode matches the application type. If the background mode does not match the application type, the system will suspend the task once it detects the issue. - Ensure that the requested continuous task background mode matches the application type. If the background mode does not match the application type, the system will suspend the task once it detects the issue.
- If a requested continuous task is not actually executed, the system will suspend the task once it detects the issue. - If a requested continuous task is not actually executed, the system will suspend the task once it detects the issue.
- Each ability can request only one continuous task at a time. - An ability can request only one continuous task at a time. If an application has multiple abilities, you can request a continuous task for each ability.
## Work Scheduler Tasks ## Work Scheduler Tasks
The Work Scheduler provides a mechanism for an application to execute a non-real-time task, for example, data learning, when the system is idle. The system places the Work Scheduler tasks requested by applications in a queue and determines the optimal scheduling time of each task based on the storage space, power consumption, temperature, and more. Persistence is supported. This means that a requested Work Scheduler task can be triggered when the application exits or the device restarts. The Work Scheduler provides a mechanism for an application to execute a non-real-time task, for example, data learning, when the system is idle. The system places the Work Scheduler tasks requested by applications in a queue and determines the optimal scheduling time of each task based on the storage space, power consumption, temperature, and more. Persistence is supported. This means that a requested Work Scheduler task can be triggered when the application exits or the device restarts.
......
...@@ -80,13 +80,13 @@ To create a WorkScheduler project in DevEco Studio, perform the following steps: ...@@ -80,13 +80,13 @@ To create a WorkScheduler project in DevEco Studio, perform the following steps:
3. In the **./entry/src/main/ets** directory under the **entry** module of the project, create a directory named **workAbility**. In the **workAbility** directory, create an ArkTS file named **WorkTest.ets** and implement the callbacks for Work Scheduler. 3. In the **./entry/src/main/ets** directory under the **entry** module of the project, create a directory named **workAbility**. In the **workAbility** directory, create an ArkTS file named **WorkTest.ets** and implement the callbacks for Work Scheduler.
Import the module. Import the module.
```ts ```ts
import { workAbility } from '@ohos/library' import { workAbility } from '@ohos/library'
``` ```
Inherit from **workAbility** and implement the lifecycle callbacks for the WorkSchedulerExtensionAbility. Inherit from **workAbility** and implement the lifecycle callbacks for the WorkSchedulerExtensionAbility.
```ts ```ts
export default class WorkTest extends workAbility { export default class WorkTest extends workAbility {
...@@ -175,10 +175,9 @@ To create a WorkScheduler project in DevEco Studio, perform the following steps: ...@@ -175,10 +175,9 @@ To create a WorkScheduler project in DevEco Studio, perform the following steps:
} }
``` ```
### Setting the Configuration File ### Setting the Configuration File
1. Register the WorkSchedulerExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) under the **entry** module. Set **type** to **workScheduler** and **srcEntrance** to the code path of the WorkSchedulerExtensionAbility component. 1. Register the WorkSchedulerExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) under the **entry** module. Set **type** to **workScheduler** and **srcEnty** to the code path of the WorkSchedulerExtensionAbility component.
```json ```json
{ {
...@@ -186,7 +185,7 @@ To create a WorkScheduler project in DevEco Studio, perform the following steps: ...@@ -186,7 +185,7 @@ To create a WorkScheduler project in DevEco Studio, perform the following steps:
"extensionAbilities": [ "extensionAbilities": [
{ {
"name": "WorkTest", "name": "WorkTest",
"srcEntrance": "./ets/workAbility/WorkTest.ets", "srcEntry": "./ets/workAbility/WorkTest.ets",
"label": "$string:WorkSchedulerExtensionAbility_label", "label": "$string:WorkSchedulerExtensionAbility_label",
"description": "$string:WorkSchedulerExtensionAbility_desc", "description": "$string:WorkSchedulerExtensionAbility_desc",
"type": "workScheduler" "type": "workScheduler"
...@@ -195,3 +194,13 @@ To create a WorkScheduler project in DevEco Studio, perform the following steps: ...@@ -195,3 +194,13 @@ To create a WorkScheduler project in DevEco Studio, perform the following steps:
} }
} }
``` ```
## Restrictions
To minimize the abuse of **WorkSchedulerExtensionAbility** by third-party applications, the following APIs cannot be invoked in **WorkSchedulerExtensionAbility**:
- @ohos.backgroundTaskManager.d.ts
- @ohos.resourceschedule.backgroundTaskManager.d.ts
- @ohos.multimedia.camera.d.ts
- @ohos.multimedia.audio.d.ts
- @ohos.multimedia.media.d.ts
...@@ -27,4 +27,9 @@ typedef enum { ...@@ -27,4 +27,9 @@ typedef enum {
### Sequential Loading (Default) ### Sequential Loading (Default)
The **priority** field (ranging from 0 to 200) in the configuration file determines the loading sequence of a host and a driver. For the drivers in different hosts, the drivers in the host with a smaller priority value are loaded first. For the drivers in the same host, the driver with a smaller priority value is loaded first. The **priority** field (ranging from 0 to 200) in the configuration file determines the loading sequence of a host and a driver. For the drivers in different hosts, the driver with a smaller priority value is loaded first. For the drivers in the same host, the driver with a smaller priority value is loaded first.
### Exception Recovery (User-Mode Driver)
The policies for restoring from a driver service exception are as follows:
- If **preload** is set to **0** (**DEVICE_PRELOAD_ENABLE**) or **1** (**DEVICE_PRELOAD_ENABLE_STEP2**) for the driver service, the startup module starts the host and reloads the service.
- If **preload** is set to **2** (**DEVICE_PRELOAD_DISABLE**), the service module needs to register an HDF service status listener. When receiving a notification on service exit, the service module calls **LoadDevice()** to reload the service.
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
- [Dynamic Loading and Linking](kernel-small-bundles-linking.md) - [Dynamic Loading and Linking](kernel-small-bundles-linking.md)
- [Virtual Dynamic Shared Object](kernel-small-bundles-share.md) - [Virtual Dynamic Shared Object](kernel-small-bundles-share.md)
- [LiteIPC](kernel-small-bundles-ipc.md) - [LiteIPC](kernel-small-bundles-ipc.md)
- [Container](kernel-small-bundles-container.md)
- File Systems - File Systems
- [Virtual File System](kernel-small-bundles-fs-virtual.md) - [Virtual File System](kernel-small-bundles-fs-virtual.md)
- [Supported File Systems](kernel-small-bundles-fs-support.md) - [Supported File Systems](kernel-small-bundles-fs-support.md)
......
此差异已折叠。
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
OpenHarmony 3.1.7 Release provides enhanced system security over OpenHarmony 3.1.6 Release by rectifying memory leak issues, certain known vulnerabilities in open-source components such as Linux kernel, and system stability issues. The matching SDK version is also updated. OpenHarmony 3.1.7 Release provides enhanced system security over OpenHarmony 3.1.6 Release by rectifying memory leak issues, certain known vulnerabilities in open-source components such as Linux kernel, and system stability issues. The matching SDK version is also updated.
## Version Mapping
## Mapping relationship **Table 1** Version mapping of software and tools
**Table 1** Version mapping of software and tools
| Software/Tool | Version | Remarks | | Software/Tool | Version | Remarks |
| ------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
...@@ -100,8 +99,6 @@ This version does not involve feature updates. ...@@ -100,8 +99,6 @@ This version does not involve feature updates.
This version does not involve API updates. This version does not involve API updates.
### Chip and Development Board Adaptation ### Chip and Development Board Adaptation
For details about the adaptation status, see [SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig_devboard/sig_devboard.md). For details about the adaptation status, see [SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig_devboard/sig_devboard.md).
...@@ -122,8 +119,6 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -122,8 +119,6 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| DFX subsystem | **libhilog.z.so** crashes in **ohos.samples.distributedmusicplayer**. ([I6DCSL](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I6DCSL))| | DFX subsystem | **libhilog.z.so** crashes in **ohos.samples.distributedmusicplayer**. ([I6DCSL](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I6DCSL))|
### Fixed Security Vulnerabilities ### Fixed Security Vulnerabilities
**Table 4** Fixed security vulnerabilities **Table 4** Fixed security vulnerabilities
...@@ -147,7 +142,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -147,7 +142,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| I6JH2L | Security vulnerabilities of the kernel_linux_4.19 component: CVE-2023-23559, CVE-2022-47929, CVE-2022-2873, and CVE-2023-23455| [PR](https://gitee.com/openharmony/kernel_linux_4.19/pulls/103) | | I6JH2L | Security vulnerabilities of the kernel_linux_4.19 component: CVE-2023-23559, CVE-2022-47929, CVE-2022-2873, and CVE-2023-23455| [PR](https://gitee.com/openharmony/kernel_linux_4.19/pulls/103) |
| I6LCHO | Security vulnerability of the kernel_linux_4.19 component: CVE-2023-0030 | [PR](https://gitee.com/openharmony/kernel_linux_4.19/pulls/111) | | I6LCHO | Security vulnerability of the kernel_linux_4.19 component: CVE-2023-0030 | [PR](https://gitee.com/openharmony/kernel_linux_4.19/pulls/111) |
## ## Known Issues
**Table 5** Known issues **Table 5** Known issues
......
此差异已折叠。
# OpenHarmony Release Notes # OpenHarmony Release Notes
## OpenHarmony 3.x Releases ## OpenHarmony 3.x Releases
- [OpenHarmony v3.2 Release (2023-04-09)](OpenHarmony-v3.2-release.md)
- [OpenHarmony v3.2 Beta5 (2023-01-31)](OpenHarmony-v3.2-beta5.md) - [OpenHarmony v3.2 Beta5 (2023-01-31)](OpenHarmony-v3.2-beta5.md)
- [OpenHarmony v3.2 Beta4 (2022-11-30)](OpenHarmony-v3.2-beta4.md) - [OpenHarmony v3.2 Beta4 (2022-11-30)](OpenHarmony-v3.2-beta4.md)
- [OpenHarmony v3.2 Beta3 (2022-09-30)](OpenHarmony-v3.2-beta3.md) - [OpenHarmony v3.2 Beta3 (2022-09-30)](OpenHarmony-v3.2-beta3.md)
- [OpenHarmony v3.2 Beta2 (2022-07-30)](OpenHarmony-v3.2-beta2.md) - [OpenHarmony v3.2 Beta2 (2022-07-30)](OpenHarmony-v3.2-beta2.md)
- [OpenHarmony v3.2 Beta1 (2022-05-31)](OpenHarmony-v3.2-beta1.md) - [OpenHarmony v3.2 Beta1 (2022-05-31)](OpenHarmony-v3.2-beta1.md)
- [OpenHarmony v3.1 Release (2022-03-30)](OpenHarmony-v3.1-release.md) - [OpenHarmony v3.1 Release (2022-03-30)](OpenHarmony-v3.1-release.md)
- [OpenHarmony v3.1.7 Release (2023-03-22)](OpenHarmony-v3.1.7-release.md)
- [OpenHarmony v3.1.6 Release (2023-01-30)](OpenHarmony-v3.1.6-release.md) - [OpenHarmony v3.1.6 Release (2023-01-30)](OpenHarmony-v3.1.6-release.md)
- [OpenHarmony v3.1.5 Release (2022-12-30)](OpenHarmony-v3.1.5-release.md) - [OpenHarmony v3.1.5 Release (2022-12-30)](OpenHarmony-v3.1.5-release.md)
- [OpenHarmony v3.1.4 Release (2022-11-02)](OpenHarmony-v3.1.4-release.md) - [OpenHarmony v3.1.4 Release (2022-11-02)](OpenHarmony-v3.1.4-release.md)
......
# HUKS Changelog
## cl.huks.1 Change of the Permission for Using attestKeyItem
The **attestKeyItem** interface attests a key using a public key encapsulated based on the device certificate chain. Any arbitrary export of the device certificate increases the risks on user privacy. Therefore, certain permissions are required for using this interface.
**Change Impact**
Applications without the **ohos.permission.ACCESS_IDS** permission or the system_basic or system_core permission cannot call **attestKeyItem()**.
**Key API/Component Changes**
- Involved APIs:
attestKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksReturnResult\>): void;
attestKeyItem(keyAlias: string, options: HuksOptions): Promise\<HuksReturnResult\>;
- Before change:
The AccessToken permission is verified only for the applications that pass in a tag related to **ATTESTATION_ID**.
- After change:
**attestKeyItem()** can be called only by a system application with the system_basic or system_core permission or an application with the **ohos.permission.ACCESS_IDS** permission.
**Adaptation Guide**
Applications with the system_basic or system_core permission can call **attestKeyItem()**. If an application with the normal permission needs to call **attestKeyItem()**, it must have the **ohos.permission.ACCESS_IDS** permission. For details about how to apply for the permission, see [ACL](../../../application-dev/security/accesstoken-overview.md#acl).
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册