“5a8f487ca391e66919bd87a9fdd60c714ee4d939”上不存在“...tracing/git@gitcode.net:openanolis/dragonwell8_jdk.git”
提交 b4b4489e 编写于 作者: zyjhandsome's avatar zyjhandsome

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

...@@ -48,7 +48,7 @@ arkXtest is divided into two parts: unit test framework and UI test framework. ...@@ -48,7 +48,7 @@ arkXtest is divided into two parts: unit test framework and UI test framework.
Software for writing test scripts: DevEco Studio 3.0 or later Software for writing test scripts: DevEco Studio 3.0 or later
Hardware for running test scripts: PC connected to a OpenHarmony device, such as the RK3568 development board Hardware for running test scripts: PC connected to an OpenHarmony device, such as the RK3568 development board
### Setting Up the Environment ### Setting Up the Environment
...@@ -63,8 +63,8 @@ Hardware for running test scripts: PC connected to a OpenHarmony device, such as ...@@ -63,8 +63,8 @@ Hardware for running test scripts: PC connected to a OpenHarmony device, such as
## Writing a Unit Test Script ## Writing a Unit Test Script
```TS ```TS
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
const delegator = abilityDelegatorRegistry.getAbilityDelegator() const delegator = abilityDelegatorRegistry.getAbilityDelegator()
export default function abilityTest() { export default function abilityTest() {
...@@ -197,11 +197,12 @@ The framework supports multiple test case execution modes, which are triggered b ...@@ -197,11 +197,12 @@ The framework supports multiple test case execution modes, which are triggered b
| breakOnError | Whether to enable break-on-error mode. When this mode is enabled, the test execution process exits if a test assertion error or any other error occurs.| **true**/**false** (default value) | -s breakOnError true | | breakOnError | Whether to enable break-on-error mode. When this mode is enabled, the test execution process exits if a test assertion error or any other error occurs.| **true**/**false** (default value) | -s breakOnError true |
| testType | Type of the test case to be executed. | function, performance, power, reliability, security, global, compatibility, user, standard, safety, resilience| -s testType function | | testType | Type of the test case to be executed. | function, performance, power, reliability, security, global, compatibility, user, standard, safety, resilience| -s testType function |
| level | Level of the test case to be executed. | 0, 1, 2, 3, 4 | -s level 0 | | level | Level of the test case to be executed. | 0, 1, 2, 3, 4 | -s level 0 |
| size | Size of the test case to be executed. | small, medium, large | -s size small | | size | Size of the test case to be executed. | small, medium, large | -s size small |
| stress | Number of times that the test case is executed. | Positive integer | -s stress 1000 |
**Running Commands** **Running Commands**
Configure hdc-related environment variables, and then perform the following: > Configure hdc-related environment variables, and then perform the following:
- Open the CLI. - Open the CLI.
- Run the **aa test** commands. - Run the **aa test** commands.
...@@ -260,12 +261,18 @@ Example 9: Execute test cases at the specified level. ...@@ -260,12 +261,18 @@ Example 9: Execute test cases at the specified level.
hdc shell aa test -b xxx -p xxx -s unittest OpenHarmonyTestRunner -s level 0 hdc shell aa test -b xxx -p xxx -s unittest OpenHarmonyTestRunner -s level 0
``` ```
Example 10: Execute test cases with the specified level. Example 10: Execute test cases with the specified size.
```shell ```shell
hdc shell aa test -b xxx -p xxx -s unittest OpenHarmonyTestRunner -s size small hdc shell aa test -b xxx -p xxx -s unittest OpenHarmonyTestRunner -s size small
``` ```
Example 11: Execute test cases for a specified number of times.
```shell
hdc shell aa test -b xxx -p xxx -s unittest OpenHarmonyTestRunner -s stress 1000
```
**Viewing the Test Result** **Viewing the Test Result**
- During test execution in the CLI, the log information similar to the following is displayed: - During test execution in the CLI, the log information similar to the following is displayed:
...@@ -394,11 +401,11 @@ Run the following command, restart the device, and execute the test case again: ...@@ -394,11 +401,11 @@ Run the following command, restart the device, and execute the test case again:
hdc shell param set persist.ace.testmode.enabled 1 hdc shell param set persist.ace.testmode.enabled 1
``` ```
#### The failure log contains "uitest-api dose not allow calling concurrently" #### The failure log contains "uitest-api does not allow calling concurrently"
**Problem** **Problem**
The UI test case fails to be executed. The HiLog file contains the error message "uitest-api dose not allow calling concurrently". The UI test case fails to be executed. The HiLog file contains the error message "uitest-api does not allow calling concurrently".
**Possible Causes** **Possible Causes**
...@@ -412,11 +419,11 @@ The UI test case fails to be executed. The HiLog file contains the error message ...@@ -412,11 +419,11 @@ The UI test case fails to be executed. The HiLog file contains the error message
2. Do not execute UI test cases in multiple processes. 2. Do not execute UI test cases in multiple processes.
#### The failure log contains "dose not exist on current UI! Check if the UI has changed after you got the widget object" #### The failure log contains "does not exist on current UI! Check if the UI has changed after you got the widget object"
**Problem** **Problem**
The UI test case fails to be executed. The HiLog file contains the error message "dose not exist on current UI! Check if the UI has changed after you got the widget object". The UI test case fails to be executed. The HiLog file contains the error message "does not exist on current UI! Check if the UI has changed after you got the widget object".
**Possible Causes** **Possible Causes**
......
...@@ -15,11 +15,11 @@ import pointer from '@ohos.multimodalInput.pointer'; ...@@ -15,11 +15,11 @@ import pointer from '@ohos.multimodalInput.pointer';
The following table lists the common APIs for mouse pointer management. For details about the APIs, see [ohos.multimodalInput.pointer](../reference/apis/js-apis-pointer.md). The following table lists the common APIs for mouse pointer management. For details about the APIs, see [ohos.multimodalInput.pointer](../reference/apis/js-apis-pointer.md).
| Instance | API | Description | | Instance | API | Description |
| ------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | ------- | ------------------------------------------------------------ | --------------------------------------------------------------- |
| pointer | function isPointerVisible(callback: AsyncCallback\<boolean>): void; | Checks the visible status of the mouse pointer. | | pointer | function isPointerVisible(callback: AsyncCallback\<boolean>): void; | Checks the visible status of the mouse pointer. |
| pointer | function setPointerVisible(visible: boolean, callback: AsyncCallback\<void>): void; | Sets the visible status of the mouse pointer. This setting takes effect for the mouse pointer globally.| | pointer | function setPointerVisible(visible: boolean, callback: AsyncCallback\<void>): void; | Sets the visible status of the mouse pointer. This setting takes effect for the mouse pointer globally. |
| pointer | function setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback\<void>): void; | Sets the mouse pointer style. This setting takes effect for the mouse pointer style of a specified window. | | pointer | function setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback\<void>): void; | Sets the mouse pointer style. This setting takes effect for the mouse pointer style of a specified window. |
| pointer | function getPointerStyle(windowId: number, callback: AsyncCallback\<PointerStyle>): void; | Obtains the mouse pointer style. | | pointer | function getPointerStyle(windowId: number, callback: AsyncCallback\<PointerStyle>): void; | Obtains the mouse pointer style. |
## Hiding the Mouse Pointer ## Hiding the Mouse Pointer
......
...@@ -39,7 +39,7 @@ Fault management is an important way for applications to deliver a better user e ...@@ -39,7 +39,7 @@ Fault management is an important way for applications to deliver a better user e
- Fault query indicates that [faultLogger](../reference/apis/js-apis-faultLogger.md) obtains the fault information using its query API. - Fault query indicates that [faultLogger](../reference/apis/js-apis-faultLogger.md) obtains the fault information using its query API.
The figure below does not illustrate the time when [faultLogger](../reference/apis/js-apis-faultLogger.md) is called. You can refer to [LastExitReason](../reference/apis/js-apis-application-abilityConstant.md#abilityconstantlastexitreason) passed during application initialization to determine whether to call [faultLogger](../reference/apis/js-apis-faultLogger.md) to query the information about the last fault. The figure below does not illustrate the time when [faultLogger](../reference/apis/js-apis-faultLogger.md) is called. You can refer to [LastExitReason](../reference/apis/js-apis-app-ability-abilityConstant.md#abilityconstantlastexitreason) passed during application initialization to determine whether to call [faultLogger](../reference/apis/js-apis-faultLogger.md) to query the information about the last fault.
![Fault rectification process](./figures/fault_rectification.png) ![Fault rectification process](./figures/fault_rectification.png)
It is recommended that you call [errorManager](../reference/apis/js-apis-application-errorManager.md) to process the exception. After the processing is complete, you can call the status saving API and restart the application. It is recommended that you call [errorManager](../reference/apis/js-apis-application-errorManager.md) to process the exception. After the processing is complete, you can call the status saving API and restart the application.
...@@ -134,7 +134,7 @@ After the callback triggers **appRecovery.saveAppState()**, **onSaveState(state, ...@@ -134,7 +134,7 @@ After the callback triggers **appRecovery.saveAppState()**, **onSaveState(state,
- Restore data. - Restore data.
After the callback triggers **appRecovery.restartApp()**, the application is restarted. After the restart, **onSaveState(state, wantParams)** of **EntryAbility** is called, and the saved data is in **parameters** of **want**. After the callback triggers **appRecovery.restartApp()**, the application is restarted. After the restart, **onCreate(want, launchParam)** of **EntryAbility** is called, and the saved data is in **parameters** of **want**.
```ts ```ts
storage: LocalStorage storage: LocalStorage
......
# HiLog Development # HiLog Development
## Introduction
## Overview
HiLog is the log system of OpenHarmony that provides logging for the system framework, services, and applications to record information on user operations and system running status. HiLog is the log system of OpenHarmony that provides logging for the system framework, services, and applications to record information on user operations and system running status.
> **NOTE** > **NOTE**
>
> This development guide is applicable only when you use Native APIs for application development. For details about the APIs, see [HiLog Native API Reference](https://gitee.com/openharmony-sig/interface_native_header/blob/master/en/native_sdk/dfx/log.h). > This development guide is applicable only when you use Native APIs for application development. For details about the APIs, see [HiLog Native API Reference](https://gitee.com/openharmony-sig/interface_native_header/blob/master/en/native_sdk/dfx/log.h).
## Available APIs ## Available APIs
| API/Macro| Description| | API/Macro| Description|
| -------- | -------- | | -------- | -------- |
| int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) | Outputs logs based on the specified log type, log level, service domain, log tag, and variable parameters determined by the format specifier and privacy identifier in the printf format.| | int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) | Outputs logs based on the specified log type, log level, service domain, log tag, and variable parameters determined by the format specifier and privacy identifier in the printf format.<br>Input parameters: See [Parameter Description](#parameter-description).<br>Output parameters: None<br>Return value: total number of bytes if log printing is successful; **-1** otherwise.|
| #define OH_LOG_DEBUG(type, ...) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__))| Outputs DEBUG logs. This is a function-like macro.| | #define OH_LOG_DEBUG(type, ...) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__))| Outputs DEBUG logs. This is a function-like macro.|
| #define OH_LOG_INFO(type, ...) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs INFO logs. This is a function-like macro.| | #define OH_LOG_INFO(type, ...) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs INFO logs. This is a function-like macro.|
| #define OH_LOG_WARN(type, ...) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs WARN logs. This is a function-like macro.| | #define OH_LOG_WARN(type, ...) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs WARN logs. This is a function-like macro.|
| #define OH_LOG_ERROR(type, ...) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs ERROR logs. This is a function-like macro.| | #define OH_LOG_ERROR(type, ...) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs ERROR logs. This is a function-like macro.|
| #define OH_LOG_FATAL(type, ...) ((void)OH_LOG_Print((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs FATAL logs. This is a function-like macro.| | #define OH_LOG_FATAL(type, ...) ((void)OH_LOG_Print((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs FATAL logs. This is a function-like macro.|
| bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level) | Checks whether logs of the specified service domain, tag, and level can be printed.<br>Input arguments:<br>- **domain**: service domain.<br>- **tag**: log tag.<br>- **level**: log level.<br>Output arguments: none<br>Return value: Returns **true** if the specified logs can be printed; returns **false** otherwise.| | bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level) | Checks whether logs of the specified service domain, tag, and level can be printed.<br>Input parameters: See [Parameter Description](#parameter-description).<br>Output arguments: none<br>Return value: **true** if the specified logs can be printed; **false** otherwise.|
## Parameter Description
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| type | enum | Yes | Enum of log printing types. The default value is **LOG_APP** for application logs.|
| level | enum | Yes | Log printing level. For details, see [Log Level](#loglevel).|
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.<br>You can define the value as required. |
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| fmt | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
## LogLevel
Log level.
| Name | Value | Description |
| ----- | ------ | ------------------------------------------------------------ |
| DEBUG | 3 | Log level used to record more detailed process information than INFO logs to help developers analyze service processes and locate faults.|
| INFO | 4 | Log level used to record key service process nodes and exceptions that occur during service running,<br>Log level used to record information about unexpected exceptions, such as network signal loss and login failure.<br>These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.|
| WARN | 5 | Log level used to record severe, unexpected faults that have little impact on users and can be rectified by the programs themselves or through simple operations.|
| ERROR | 6 | Log level used to record program or functional errors that affect the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.|
| FATAL | 7 | Log level used to record program or functionality crashes that cannot be rectified.
## Development Examples ## Development Examples
1. Include the **hilog** header file in the source file.
1. Add the link of **libhilog_ndk.z.so** to **CMakeLists.txt**:
```
target_link_libraries(entry PUBLIC libhilog_ndk.z.so)
```
2. Include the **hilog** header file in the source file, and define the **domain** and **tag** macros.
```c++ ```c++
#include "hilog/log.h" #include "hilog/log.h"
``` ```
2. Define the **domain** and **tag** macros.
```c++ ```c++
#undef LOG_DOMAIN #undef LOG_DOMAIN
#undef LOG_TAG #undef LOG_TAG
#define LOG_DOMAIN 0x3200 // Service domain. The value ranges from 0xD0000 to 0xDFFFF. #define LOG_DOMAIN 0x3200 // Global domain, which identifies the service domain.
#define LOG_TAG "MY_TAG" #define LOG_TAG "MY_TAG" // Global tag, which identifies the module log tag.
``` ```
3. Print logs. For example, to print INFO logs, use the following code: 3. Print logs. For example, to print ERROR logs, use the following code:
```c++ ```c++
OH_LOG_INFO(LOG_APP, "Failed to visit %{private}s, reason:%{public}d.", url, errno); OH_LOG_ERROR(LOG_APP, "Failed to visit %{private}s, reason:%{public}d.", url, errno);
``` ```
4. View the output log information. 4. View the output log information.
``` ```
12-11 12:21:47.579 2695 2695 I A03200/MY_TAG: Failed to visit <private>, reason:11. 12-11 12:21:47.579 2695 2695 E A03200/MY_TAG: Failed to visit <private>, reason:11.
``` ```
...@@ -87,7 +87,7 @@ The development process consists of the following main steps: ...@@ -87,7 +87,7 @@ The development process consists of the following main steps:
The required model can be downloaded directly or obtained using the model conversion tool. The required model can be downloaded directly or obtained using the model conversion tool.
- If the downloaded model is in the `.ms` format, you can use it directly for inference. The following uses the **mobilenetv2.ms** model as an example. - If the downloaded model is in the `.ms` format, you can use it directly for inference. The following uses the **mobilenetv2.ms** model as an example.
- If the downloaded model uses a third-party framework, such as TensorFlow, TensorFlow Lite, Caffe, or ONNX, you can use the [model conversion tool](https://www.mindspore.cn/lite/docs/zh-CN/r1.5/use/downloads.html#id1) to convert it to the `.ms` format. - If the downloaded model uses a third-party framework, such as TensorFlow, TensorFlow Lite, Caffe, or ONNX, you can use the [model conversion tool](https://www.mindspore.cn/lite/docs/en/r1.5/use/downloads.html#id1) to convert it to the `.ms` format.
2. Create a context, and set parameters such as the number of runtime threads and device type. 2. Create a context, and set parameters such as the number of runtime threads and device type.
......
...@@ -41,7 +41,7 @@ This document gives an overview of the **module.json5** configuration file. To s ...@@ -41,7 +41,7 @@ This document gives an overview of the **module.json5** configuration file. To s
"entity.system.home" "entity.system.home"
], ],
"actions": [ "actions": [
"action.system.home" "ohos.want.action.home"
] ]
} }
] ]
...@@ -74,15 +74,15 @@ As shown above, the **module.json5** file contains several tags. ...@@ -74,15 +74,15 @@ As shown above, the **module.json5** file contains several tags.
| name | Name of the module. The value is a string with a maximum of 31 bytes and must be unique in the entire application.| String| No| | name | Name of the module. The value is a string with a maximum of 31 bytes and must be unique in the entire application.| String| No|
| type | Type of the module. The value can be **entry** or **feature**.<br>- **entry**: main module of the application.<br>- **feature**: dynamic feature module of the application.| String| No| | type | Type of the module. The value can be **entry** or **feature**.<br>- **entry**: main module of the application.<br>- **feature**: dynamic feature module of the application.| String| No|
| srcEntrance | Code path corresponding to the module. The value is a string with a maximum of 127 bytes.| String| Yes (initial value: left empty)| | srcEntrance | Code path corresponding to the module. The value is a string with a maximum of 127 bytes.| String| Yes (initial value: left empty)|
| description | Description of the module. The value is a string with a maximum of 255 bytes or a string resource index. | String| Yes (initial value: left empty)| | description | Description of the module. The value is a string with a maximum of 255 bytes or a string resource index.| String| Yes (initial value: left empty)|
| process | Process name of the current module. The value is a string with a maximum of 31 bytes. If **process** is configured under **HAP**, all UIAbility, DataShareExtensionAbility, and ServiceExtensionAbility components of the application run in the specified process.<br>**NOTE**<br>This tag applies only to system applications and does not take effect for third-party applications.| String| Yes (initial value: value of **bundleName** under **app** in the **app.json5** file)| | process | Process name of the current module. The value is a string with a maximum of 31 bytes. If **process** is configured under **HAP**, all UIAbility, DataShareExtensionAbility, and ServiceExtensionAbility components of the application run in the specified process.<br>**NOTE**<br>This tag applies only to system applications and does not take effect for third-party applications.| String| Yes (initial value: value of **bundleName** under **app** in the **app.json5** file)|
| mainElement | Name of the entry UIAbility or ExtensionAbility of the module. The value contains a maximum of 255 bytes.| String| Yes (initial value: left empty)| | mainElement | Name of the entry UIAbility or ExtensionAbility of the module. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)|
| [deviceTypes](#devicetypes) | Type of the device on which the module can run.| String array| No (can be left empty)| | [deviceTypes](#devicetypes) | Type of the device on which the module can run.| String array| No (can be left empty)|
| deliveryWithInstall | Whether the HAP file of the module will be installed when the user installs the application.<br>- **true**: The HAP file will be installed when the user installs the application.<br>- **false**: The HAP file will not be installed when the user installs the application.| Boolean| No| | deliveryWithInstall | Whether the HAP file of the module will be installed when the user installs the application.<br>- **true**: The HAP file will be installed when the user installs the application.<br>- **false**: The HAP file will not be installed when the user installs the application.| Boolean| No|
| installationFree | Whether the module supports the installation-free feature.<br>- **true**: The module supports the installation-free feature and meets installation-free constraints.<br>- **false**: The module does not support the installation-free feature.<br>**NOTE**<br>- If this tag is set to **true** for an entry-type module, it must also be set to **true** for feature-type modules of the same application.<br>- If this tag is set to **false** for an entry-type module, it can be set to **true** or **false** for feature-type modules of the same application based on service requirements.| Boolean| No| | installationFree | Whether the module supports the installation-free feature.<br>- **true**: The module supports the installation-free feature and meets installation-free constraints.<br>- **false**: The module does not support the installation-free feature.<br>**NOTE**<br>- If this tag is set to **true** for an entry-type module, it must also be set to **true** for feature-type modules of the same application.<br>- If this tag is set to **false** for an entry-type module, it can be set to **true** or **false** for feature-type modules of the same application based on service requirements.| Boolean| No|
| virtualMachine | Type of the target virtual machine (VM) where the module runs. It is used for cloud distribution, such as distribution by the application market and distribution center.<br>If the target VM type is ArkTS engine, the value is **ark**+*version number*. | String| Yes (initial value: automatically inserted when DevEco Studio builds the HAP file)| | virtualMachine | Type of the target virtual machine (VM) where the module runs. It is used for cloud distribution, such as distribution by the application market and distribution center.<br> If the target VM type is ArkTS engine, the value is **ark**+*version number*.| String| Yes (initial value: automatically inserted when DevEco Studio builds the HAP file)|
| uiSyntax (deprecated)| Syntax type of the JS component defined by the module syntax. This tag is deprecated since API version 9.<br>- **"hml"**: The JS component is developed using HML, CSS, or JS.<br>- **"ets"**: The JS component is developed using ArkTS. | String| Yes (initial value: **"hml"**)| | uiSyntax (deprecated)| Syntax type of the component defined by the module syntax. This tag is deprecated since API version 9.<br>- **"hml"**: The component is developed using HML, CSS, or JS.<br>- **"ets"**: The component is developed using ArkTS.| String| Yes (initial value: **"hml"**)|
| [pages](#pages)| Profile that represents information about each page in the JS component. The value can contain a maximum of 255 bytes.| String| No in the UIAbility scenario| | [pages](#pages)| Profile that represents information about each page in the current module. The value can contain a maximum of 255 bytes.| String| No in the UIAbility scenario|
| [metadata](#metadata)| Custom metadata of the module. The setting is valid only for the current module, UIAbility, or ExtensionAbility.| Object array| Yes (initial value: left empty)| | [metadata](#metadata)| Custom metadata of the module. The setting is valid only for the current module, UIAbility, or ExtensionAbility.| Object array| Yes (initial value: left empty)|
| [abilities](#abilities) | UIAbility configuration of the module, which is valid only for the current UIAbility component.| Object| Yes (initial value: left empty)| | [abilities](#abilities) | UIAbility configuration of the module, which is valid only for the current UIAbility component.| Object| Yes (initial value: left empty)|
| [extensionAbilities](#extensionabilities) | ExtensionAbility configuration of the module, which is valid only for the current ExtensionAbility component.| Object| Yes (initial value: left empty)| | [extensionAbilities](#extensionabilities) | ExtensionAbility configuration of the module, which is valid only for the current ExtensionAbility component.| Object| Yes (initial value: left empty)|
...@@ -157,7 +157,7 @@ The **metadata** tag represents the custom metadata of the HAP file. The tag val ...@@ -157,7 +157,7 @@ The **metadata** tag represents the custom metadata of the HAP file. The tag val
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | Name of the data item. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)| | name | Name of the data item. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)|
| value | Value of the data item. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)| | value | Value of the data item. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)|
| resource | Custom data format. The value is a resource index. It contains a maximum of 255 bytes. | String| Yes (initial value: left empty)| | resource | Custom data format. The value is a resource index that identifies the data. It contains a maximum of 255 bytes.| String| Yes (initial value: left empty)|
```json ```json
...@@ -210,14 +210,14 @@ The **abilities** tag describes the UIAbility configuration of the component, wh ...@@ -210,14 +210,14 @@ The **abilities** tag describes the UIAbility configuration of the component, wh
| name | Name of the UIAbility component, which must be unique in the entire application. The value is a string with a maximum of 127 bytes.| String| No| | name | Name of the UIAbility component, which must be unique in the entire application. The value is a string with a maximum of 127 bytes.| String| No|
| srcEntrance | Code path of the entry UIAbility component. The value is a string with a maximum of 127 bytes.| String| No| | srcEntrance | Code path of the entry UIAbility component. The value is a string with a maximum of 127 bytes.| String| No|
| [launchType](../application-models/uiability-launch-type.md) | Launch type of the UIAbility component. The options are as follows:<br>- **standard**: A new UIAbility instance is created each time the UIAbility component is started.<br>- **singleton**: A new UIAbility instance is created only when the UIAbility component is started for the first time.<br>- **specified**: You can determine whether to create a new UIAbility instance when the application is running.| String| Yes (initial value: **"singleton"**)| | [launchType](../application-models/uiability-launch-type.md) | Launch type of the UIAbility component. The options are as follows:<br>- **standard**: A new UIAbility instance is created each time the UIAbility component is started.<br>- **singleton**: A new UIAbility instance is created only when the UIAbility component is started for the first time.<br>- **specified**: You can determine whether to create a new UIAbility instance when the application is running.| String| Yes (initial value: **"singleton"**)|
| description | Description of the UIAbility component. The value is a string with a maximum of 255 bytes or a resource index to the description in multiple languages. | String| Yes (initial value: left empty)| | description | Description of the UIAbility component. The value is a string with a maximum of 255 bytes or a resource index to the description in multiple languages.| String| Yes (initial value: left empty)|
| icon | Icon of the UIAbility component. The value is an icon resource index.<br/>If **UIAbility** is set to **MainElement** of the current module, this attribute is mandatory. | String| Yes (initial value: left empty) | | icon | Icon of the UIAbility component. The value is an icon resource index.<br/>If **UIAbility** is set to **MainElement**, this attribute is mandatory. | String| Yes (initial value: left empty) |
| label | Name of the UIAbility component displayed to users. The value is a string resource index.<br>If **UIAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application. | String| No| | label | Name of the UIAbility component displayed to users. The value is a string resource index.<br>If **UIAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| No|
| permissions | Permissions required for another application to access the UIAbility component.<br>The value is an array of permission names predefined by the system, generally in the reverse domain name notation. It contains a maximum of 255 bytes.| String array| Yes (initial value: left empty)| | permissions | Permissions required for another application to access the UIAbility component.<br>The value is an array of permission names predefined by the system, generally in the reverse domain name notation. It contains a maximum of 255 bytes.| String array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)| | [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)|
| visible | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| | visible | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
| continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)| | continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)|
| [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuring rule:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **action.system.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)| | [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuring rule:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)|
| backgroundModes | Continuous tasks of the UIAbility component.<br>Continuous tasks are classified into the following types:<br>- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.<br>- **audioPlayback**: audio playback service.<br>- **audioRecording**: audio recording service.<br>- **location**: location and navigation services.<br>- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).<br>- **multiDeviceConnection**: multi-device interconnection service.<br>- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)<br>- **voip**: voice/video call and VoIP services.<br>- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)| | backgroundModes | Continuous tasks of the UIAbility component.<br>Continuous tasks are classified into the following types:<br>- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.<br>- **audioPlayback**: audio playback service.<br>- **audioRecording**: audio recording service.<br>- **location**: location and navigation services.<br>- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).<br>- **multiDeviceConnection**: multi-device interconnection service.<br>- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)<br>- **voip**: voice/video call and VoIP services.<br>- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)|
| startWindowIcon | Index to the icon file of the UIAbility component startup page. Example: **$media:icon**.<br>The value is a string with a maximum of 255 bytes.| String| No| | startWindowIcon | Index to the icon file of the UIAbility component startup page. Example: **$media:icon**.<br>The value is a string with a maximum of 255 bytes.| String| No|
| startWindowBackground | Index to the background color resource file of the UIAbility component startup page. Example: **$color:red**.<br>The value is a string with a maximum of 255 bytes.| String| No| | startWindowBackground | Index to the background color resource file of the UIAbility component startup page. Example: **$color:red**.<br>The value is a string with a maximum of 255 bytes.| String| No|
...@@ -250,7 +250,7 @@ Example of the **abilities** structure: ...@@ -250,7 +250,7 @@ Example of the **abilities** structure:
"visible": true, "visible": true,
"continuable": true, "continuable": true,
"skills": [{ "skills": [{
"actions": ["action.system.home"], "actions": ["ohos.want.action.home"],
"entities": ["entity.system.home"], "entities": ["entity.system.home"],
"uris": [] "uris": []
}], }],
...@@ -298,11 +298,11 @@ The **skills** tag represents the feature set of [wants](../application-models/w ...@@ -298,11 +298,11 @@ The **skills** tag represents the feature set of [wants](../application-models/w
| Name| Description| Data Type| Initial Value Allowed| | Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| scheme | Scheme of the URI, such as HTTP, HTTPS, file, and FTP.| String| Yes when only **type** is set in **uris** (initial value: left empty) | | scheme | Scheme of the URI, such as HTTP, HTTPS, file, and FTP.| String| Yes when only **type** is set in **uris** (initial value: left empty)|
| host | Host address of the URI. This attribute is valid only when **schema** is set. Common methods:<br>- domain name, for example, **example.com**.<br>- IP address, for example, **10.10.10.1**.| String| Yes (initial value: left empty)| | host | Host address of the URI. This attribute is valid only when **schema** is set. Common methods:<br>- domain name, for example, **example.com**.<br>- IP address, for example, **10.10.10.1**.| String| Yes (initial value: left empty)|
| port | Port number of the URI. For example, the default HTTP port number is 80, the default HTTPS port number is 443, and the default FTP port number is 21. This attribute is valid only when both **scheme** and **host** are set.| String| Yes (initial value: left empty)| | port | Port number of the URI. For example, the default HTTP port number is 80, the default HTTPS port number is 443, and the default FTP port number is 21. This attribute is valid only when both **scheme** and **host** are set.| String| Yes (initial value: left empty)|
| path \| pathStartWith \| pathRegex | Path of the URI. **path**, **pathStartWith**, and **pathRegex** represent different matching modes between the paths in the URI and the want. Set any one of them as needed. **path** indicates full matching, **pathStartWith** indicates prefix matching, and **pathRegex** indicates regular expression matching. This attribute is valid only when both **scheme** and **host** are set.| String| Yes (initial value: left empty)| | path \| pathStartWith \| pathRegex | Path of the URI. **path**, **pathStartWith**, and **pathRegex** represent different matching modes between the paths in the URI and the want. Set any one of them as needed. **path** indicates full matching, **pathStartWith** indicates prefix matching, and **pathRegex** indicates regular expression matching. This attribute is valid only when both **scheme** and **host** are set.| String| Yes (initial value: left empty)|
| type | Data type that matches the want. The value compiles with the [Multipurpose Internet Mail Extensions (MIME)](https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com %E3%80%82) type specification. This attribute can be configured together with **scheme** or be configured separately. | String| Yes (initial value: left empty)| | type | Data type that matches the want. The value compiles with the Multipurpose Internet Mail Extensions (MIME) type specification. This attribute can be configured together with **scheme** or be configured separately.| String| Yes (initial value: left empty)|
Example of the **skills** structure: Example of the **skills** structure:
...@@ -314,7 +314,7 @@ Example of the **skills** structure: ...@@ -314,7 +314,7 @@ Example of the **skills** structure:
"skills": [ "skills": [
{ {
"actions": [ "actions": [
"action.system.home" "ohos.want.action.home"
], ],
"entities": [ "entities": [
"entity.system.home" "entity.system.home"
...@@ -346,15 +346,15 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie ...@@ -346,15 +346,15 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | Name of the ExtensionAbility component. The value is a string with a maximum of 127 bytes. The name must be unique in the entire application.| String| No| | name | Name of the ExtensionAbility component. The value is a string with a maximum of 127 bytes. The name must be unique in the entire application.| String| No|
| srcEntrance | Code path corresponding to the ExtensionAbility component. The value is a string with a maximum of 127 bytes.| String| No| | srcEntrance | Code path corresponding to the ExtensionAbility component. The value is a string with a maximum of 127 bytes.| String| No|
| description | Description of the ExtensionAbility component. The value is a string with a maximum of 255 bytes or a resource index to the description. | String| Yes (initial value: left empty)| | description | Description of the ExtensionAbility component. The value is a string with a maximum of 255 bytes or a resource index to the description.| String| Yes (initial value: left empty)|
| icon | Icon of the ExtensionAbility component. The value is the index to an icon resource file. If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| Yes (initial value: left empty)| | icon | Icon of the ExtensionAbility component. The value is an icon resource index. If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| Yes (initial value: left empty)|
| label | Name of the ExtensionAbility component displayed to users. The value is the index to a string resource.<br>**NOTE**<br>If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| No| | label | Name of the ExtensionAbility component displayed to users. The value is a string resource index.<br>**NOTE**<br>If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| No|
| type | Type of the ExtensionAbility component. The options are as follows:<br>- **form**: ExtensionAbility of a widget.<br>- **workScheduler**: ExtensionAbility of a Work Scheduler task.<br>- **inputMethod**: ExtensionAbility of an input method.<br>- **service**: service component running in the background.<br>- **accessibility**: ExtensionAbility of an accessibility feature.<br>- **dataShare**: ExtensionAbility for data sharing.<br>- **fileShare**: ExtensionAbility for file sharing.<br>- **staticSubscriber**: ExtensionAbility for static broadcast.<br>- **wallpaper**: ExtensionAbility of the wallpaper.<br>- **backup**: ExtensionAbility for data backup.<br>- **window**: ExtensionAbility of a window. This type of ExtensionAbility creates a window during startup for which you can develop the GUI. The window is then combined with other application windows through **abilityComponent**.<br>- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.<br>- **preview**: ExtensionAbility for preview. This type of ExtensionAbility can parse the file and display it in a window. You can combine the window with other application windows.<br>**NOTE**<br>The **service** and **dataShare** types apply only to system applications and do not take effect for third-party applications. | String| No| | type | Type of the ExtensionAbility component. The options are as follows:<br>- **form**: ExtensionAbility of a widget.<br>- **workScheduler**: ExtensionAbility of a Work Scheduler task.<br>- **inputMethod**: ExtensionAbility of an input method.<br>- **service**: service component running in the background.<br>- **accessibility**: ExtensionAbility of an accessibility feature.<br>- **dataShare**: ExtensionAbility for data sharing.<br>- **fileShare**: ExtensionAbility for file sharing.<br>- **staticSubscriber**: ExtensionAbility for static broadcast.<br>- **wallpaper**: ExtensionAbility of the wallpaper.<br>- **backup**: ExtensionAbility for data backup.<br>- **window**: ExtensionAbility of a window. This type of ExtensionAbility creates a window during startup for which you can develop the GUI. The window is then combined with other application windows through **abilityComponent**.<br>- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.<br>- **preview**: ExtensionAbility for preview. This type of ExtensionAbility can parse the file and display it in a window. You can combine the window with other application windows.<br>**NOTE**<br>The **service** and **dataShare** types apply only to system applications and do not take effect for third-party applications. | String| No|
| permissions | Permissions required for another application to access the ExtensionAbility component.<br>The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of permission names predefined by the system or customized. The name of a customized permission must be the same as the **name** value of a permission defined in the **defPermissions** attribute.| String array| Yes (initial value: left empty)| | permissions | Permissions required for another application to access the ExtensionAbility component.<br>The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of permission names predefined by the system or customized. The name of a customized permission must be the same as the **name** value of a permission defined in the **defPermissions** attribute.| String array| Yes (initial value: left empty)|
| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.<br>**NOTE**<br>This attribute is mandatory when **type** of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)| | uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.<br>**NOTE**<br>This attribute is mandatory when **type** of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)|
|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.<br>Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **action.system.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.<br>**NOTE**<br>The **skills** attribute with the entry capability can be configured for the feature-type package of an OpenHarmony application, but not for an OpenHarmony service. | Array| Yes (initial value: left empty)| |skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.<br>Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.<br>**NOTE**<br>The **skills** attribute with the entry capability can be configured for the feature-type package of an OpenHarmony application, but not for an OpenHarmony service. | Array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)| | [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)|
| visible | Whether the ExtensionAbility component can be called by other applications. <br>- **true**: The ExtensionAbility component can be called by other applications.<br>- **false**: The ExtensionAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| | visible | Whether the ExtensionAbility component can be called by other applications. <br>- **true**: The ExtensionAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
Example of the **extensionAbilities** structure: Example of the **extensionAbilities** structure:
...@@ -401,7 +401,7 @@ The **requestPermissions** tage represents a set of permissions that the applica ...@@ -401,7 +401,7 @@ The **requestPermissions** tage represents a set of permissions that the applica
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| name | Permission name. This attribute is mandatory.| String| Custom| –| | name | Permission name. This attribute is mandatory.| String| Custom| –|
| reason | Reason for requesting the permission. This attribute is mandatory when the permission to request is **user_grant**.<br>**NOTE**<br>If the permission to request is **user_grant**, this attribute is required for the application to be released to the application market, and multi-language adaptation is required. | String| Resource reference of the string type in $string: \*\*\* format| A null value| | reason | Reason for requesting the permission. This attribute is mandatory when the permission to request is **user_grant**.<br>**NOTE**<br>If the permission to request is **user_grant**, this attribute is required for the application to be released to the application market, and multi-language adaptation is required. | String| Resource reference of the string type in $string: \*\*\* format| A null value|
| usedScene | Scene under which the permission is used. It consists of the **abilities** and **when** sub-attributes. Multiple abilities can be configured.<br>**NOTE**<br>This attribute is optional by default. If the permission to request is **user_grant**, the **abilities** sub-attribute is mandatory and **when** is optional. | **abilities**: string array<br>**when**: string| **abilities**: array of names of UIAbility or ExtensionAbility components<br>**when**: **inuse** or **always**| **abilities**: null<br>**when**: null| | usedScene | Scene under which the permission is used. It consists of the **abilities** and **when** sub-attributes. Multiple abilities can be configured.<br>**NOTE**<br>This attribute is optional by default. If the permission to request is **user_grant**, the **abilities** sub-attribute is mandatory and **when** is optional.| **abilities**: string array<br>**when**: string| **abilities**: array of names of UIAbility or ExtensionAbility components<br>**when**: **inuse** or **always**| **abilities**: null<br>**when**: null|
Example of the **requestPermissions** structure: Example of the **requestPermissions** structure:
...@@ -440,7 +440,7 @@ The **shortcut** information is identified in **metadata**, where: ...@@ -440,7 +440,7 @@ The **shortcut** information is identified in **metadata**, where:
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| shortcutId | ID of the shortcut. The value is a string with a maximum of 63 bytes.| String| No| | shortcutId | ID of the shortcut. The value is a string with a maximum of 63 bytes.| String| No|
| label | Label of the shortcut, that is, the text description displayed for the shortcut. The value can be a string or a resource index to the label, with a maximum of 255 bytes.| String| Yes (initial value: left empty)| | label | Label of the shortcut, that is, the text description displayed for the shortcut. The value can be a string or a resource index to the label, with a maximum of 255 bytes.| String| Yes (initial value: left empty)|
| icon | Icon of the shortcut. The value is an icon resource index. | String| Yes (initial value: left empty)| | icon | Icon of the shortcut. The value is an icon resource index.| String| Yes (initial value: left empty)|
| [wants](../application-models/want-overview.md) | Wants to which the shortcut points. Each want consists of the **bundleName** and **abilityName** sub-attributes.<br>**bundleName**: target bundle name of the shortcut. The value is a string.<br>**abilityName**: target component name of the shortcut. The value is a string.| Object| Yes (initial value: left empty)| | [wants](../application-models/want-overview.md) | Wants to which the shortcut points. Each want consists of the **bundleName** and **abilityName** sub-attributes.<br>**bundleName**: target bundle name of the shortcut. The value is a string.<br>**abilityName**: target component name of the shortcut. The value is a string.| Object| Yes (initial value: left empty)|
...@@ -481,7 +481,7 @@ The **shortcut** information is identified in **metadata**, where: ...@@ -481,7 +481,7 @@ The **shortcut** information is identified in **metadata**, where:
"entity.system.home" "entity.system.home"
], ],
"actions": [ "actions": [
"action.system.home" "ohos.want.action.home"
] ]
} }
], ],
...@@ -509,8 +509,8 @@ The **distroFilter** tag defines the rules for distributing HAP files based on d ...@@ -509,8 +509,8 @@ The **distroFilter** tag defines the rules for distributing HAP files based on d
| apiVersion | Supported API versions.| Object array| Yes (initial value: left empty)| | apiVersion | Supported API versions.| Object array| Yes (initial value: left empty)|
| screenShape | Supported screen shapes.| Object array| Yes (initial value: left empty)| | screenShape | Supported screen shapes.| Object array| Yes (initial value: left empty)|
| screenWindow | Supported window resolutions for when the application is running. This attribute applies only to the lite wearables.| Object array| Yes (initial value: left empty)| | screenWindow | Supported window resolutions for when the application is running. This attribute applies only to the lite wearables.| Object array| Yes (initial value: left empty)|
| screenDensity | Pixel density of the screen, in dots per inch (DPI). This attribute is optional. The options are as follows:<br>- **sdpi**: small-scale DPI. This value is applicable to devices with a DPI range of (0, 120].<br>- **mdpi**: medium-scale DPI. This value is applicable to devices with a DPI range of (120, 160].<br>- **ldpi**: large-scale DPI. This value is applicable to devices with a DPI range of (160, 240].<br>- **xldpi**: extra-large-scale DPI. This value is applicable to devices with a DPI range of (240, 320].<br>- **xxldpi**: extra-extra-large-scale DPI. This value is applicable to devices with a DPI range of (320, 480].<br>- **xxxldpi**: extra-extra-extra-large-scale DPI. This value is applicable to devices with a DPI range of (480, 640]. | Object array| Yes (initial value: left empty)| | screenDensity | Pixel density of the screen, in dots per inch (DPI). This attribute is optional. The value options are as follows:<br>- **sdpi**: small-scale DPI. This value is applicable to devices with a DPI range of (0, 120].<br>- **mdpi**: medium-scale DPI. This value is applicable to devices with a DPI range of (120, 160].<br>- **ldpi**: large-scale DPI. This value is applicable to devices with a DPI range of (160, 240].<br>- **xldpi**: extra-large-scale DPI. This value is applicable to devices with a DPI range of (240, 320].<br>- **xxldpi**: extra-extra-large-scale DPI. This value is applicable to devices with a DPI range of (320, 480].<br>- **xxxldpi**: extra-extra-extra-large-scale DPI. This value is applicable to devices with a DPI range of (480, 640].| Object array| Yes (initial value: left empty)|
| countryCode | Code of the country or region to which the application is to be distributed. The value is subject to the [ISO-3166-1](https://developer.harmonyos.com/en/docs/documentation/doc-guides/basic-resource-file-categories-0000001052066099) standard. Enumerated definitions of multiple countries and regions are supported.| Object array| Yes (initial value: left empty)| | countryCode | Code of the country or region to which the application is to be distributed. The value is subject to the ISO-3166-1 standard. Enumerated definitions of multiple countries and regions are supported.| Object array| Yes (initial value: left empty)|
**Table 10** apiVersion **Table 10** apiVersion
...@@ -619,7 +619,7 @@ The **testRunner** tag represents the supported test runner. ...@@ -619,7 +619,7 @@ The **testRunner** tag represents the supported test runner.
| Name| Description| Data Type| Initial Value Allowed| | Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | Name of the test runner object. The value is a string with a maximum of 255 bytes.| String| No| | name | Name of the test runner object. The value is a string with a maximum of 255 bytes.| String| No|
| srcPath | Code path of the test runner. The value is a string with a maximum of 255 bytes. | String| No| | srcPath | Code path of the test runner. The value is a string with a maximum of 255 bytes.| String| No|
Example of the / structure: Example of the / structure:
......
...@@ -9,7 +9,7 @@ The **AccessibilityExtensionAbility** module provides accessibility extension ca ...@@ -9,7 +9,7 @@ The **AccessibilityExtensionAbility** module provides accessibility extension ca
## Modules to Import ## Modules to Import
```ts ```ts
import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility' import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
``` ```
## Attributes ## Attributes
...@@ -31,7 +31,7 @@ Defines an accessibility event. ...@@ -31,7 +31,7 @@ Defines an accessibility event.
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| --------- | ---------------------------------------- | ---- | ---- | ---------- | | --------- | ---------------------------------------- | ---- | ---- | ---------- |
| eventType | [accessibility.EventType](js-apis-accessibility.md#EventType) \| [accessibility.WindowUpdateType](js-apis-accessibility.md#WindowUpdateType) \| [TouchGuideType](#touchguidetype) \| [GestureType](#gesturetype) \| [PageUpdateType](#pageupdatetype) | Yes | No | Event type. | | eventType | [accessibility.EventType](js-apis-accessibility.md#EventType) \| [accessibility.WindowUpdateType](js-apis-accessibility.md#WindowUpdateType) \| [TouchGuideType](#touchguidetype) \| [GestureType](#gesturetype) \| [PageUpdateType](#pageupdatetype) | Yes | No | Event type. |
| target | AccessibilityElement | Yes | No | Target component where the event occurs.| | target | [AccessibilityElement](js-apis-inner-application-accessibilityExtensionContext.md#accessibilityelement9) | Yes | No | Target component where the event occurs.|
| timeStamp | number | Yes | No | Timestamp of the event. | | timeStamp | number | Yes | No | Timestamp of the event. |
## GestureType ## GestureType
...@@ -78,8 +78,8 @@ Enumerates the touch guide event types. ...@@ -78,8 +78,8 @@ Enumerates the touch guide event types.
| Name | Description | | Name | Description |
| ---------- | ------------ | | ---------- | ------------ |
| touchBegin | Start of touch in touch guide mode. | | touchBegin | Start of touch in touch guide mode.|
| touchEnd | End of touch in touch guide mode. | | touchEnd | End of touch in touch guide mode.|
## AccessibilityExtensionAbility.onConnect ## AccessibilityExtensionAbility.onConnect
...@@ -137,7 +137,7 @@ Called when an event that matches the specified bundle and event type occurs. In ...@@ -137,7 +137,7 @@ Called when an event that matches the specified bundle and event type occurs. In
class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
onAccessibilityEvent(event) { onAccessibilityEvent(event) {
console.log('AxExtensionAbility onAccessibilityEvent'); console.log('AxExtensionAbility onAccessibilityEvent');
if (event.eventType == 'click') { if (event.eventType === 'click') {
console.log('AxExtensionAbility onAccessibilityEvent: click'); console.log('AxExtensionAbility onAccessibilityEvent: click');
} }
} }
...@@ -164,7 +164,7 @@ Called when a physical key is pressed. In this API, you can determine whether to ...@@ -164,7 +164,7 @@ Called when a physical key is pressed. In this API, you can determine whether to
class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
onKeyEvent(keyEvent) { onKeyEvent(keyEvent) {
console.log('AxExtensionAbility onKeyEvent'); console.log('AxExtensionAbility onKeyEvent');
if (keyEvent.keyCode == 22) { if (keyEvent.keyCode === 22) {
console.log('AxExtensionAbility onKeyEvent: intercept 22'); console.log('AxExtensionAbility onKeyEvent: intercept 22');
return true; return true;
} }
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
The **batteryInfo** module provides APIs for querying the charger type, battery health status, and battery charging status. The **batteryInfo** module provides APIs for querying the charger type, battery health status, and battery charging status.
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 6. 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 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
```js ```js
...@@ -20,18 +22,18 @@ Describes battery information. ...@@ -20,18 +22,18 @@ Describes battery information.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| --------------- | ------------------- | ---- | ---- | ---------------------| | --------------- | ------------------- | ---- | ---- | ---------------------|
| batterySOC | number | Yes | No | Battery state of charge (SoC) of the device, in unit of percentage. | | batterySOC | number | Yes | No | Battery state of charge (SoC) of the device, in unit of percentage. |
| chargingStatus | [BatteryChargeState](#batterychargestate) | Yes | No | Battery charging state of the device. | | chargingStatus | [BatteryChargeState](#batterychargestate) | Yes | No | Battery charging status of the device. |
| healthStatus | [BatteryHealthState](#batteryhealthstate) | Yes | No | Battery health state of the device. | | healthStatus | [BatteryHealthState](#batteryhealthstate) | Yes | No | Battery health status of the device. |
| pluggedType | [BatteryPluggedType](#batterypluggedtype) | Yes | No | Charger type of the device. | | pluggedType | [BatteryPluggedType](#batterypluggedtype) | Yes | No | Charger type of the device. |
| voltage | number | Yes | No | Battery voltage of the device, in unit of microvolt. | | voltage | number | Yes | No | Battery voltage of the device, in unit of microvolt. |
| technology | string | Yes | No | Battery technology of the device. | | technology | string | Yes | No | Battery technology of the device. |
| batteryTemperature | number | Yes | No | Battery temperature of the device, in unit of 0.1°C. | | batteryTemperature | number | Yes | No | Battery temperature of the device, in unit of 0.1°C. |
| isBatteryPresent<sup>7+</sup> | boolean | Yes | No | Whether the battery is supported or present. | | isBatteryPresent<sup>7+</sup> | boolean | Yes | No | Whether the battery is supported or present. |
| batteryCapacityLevel<sup>9+</sup> | [BatteryCapacityLevel](#batterycapacitylevel9) | Yes | No | Battery level of the device. | | batteryCapacityLevel<sup>9+</sup> | [BatteryCapacityLevel](#batterycapacitylevel9) | Yes | No | Battery level of the device. |
| estimatedRemainingChargeTime<sup>9+</sup> | number | Yes | No | Estimated time for fully charging the current device, in unit of milliseconds. | | estimatedRemainingChargeTime<sup>9+</sup> | number | Yes | No | Estimated time for fully charging the current device, in unit of milliseconds. **System API**: This is a system API. |
| totalEnergy<sup>9+</sup> | number | Yes | No | Total battery capacity of the device, in unit of mAh. This is a system API. | | totalEnergy<sup>9+</sup> | number | Yes | No | Total battery capacity of the device, in unit of mAh. **System API**: This is a system API. |
| nowCurrent<sup>9+</sup> | number | Yes | No | Battery current of the device, in unit of mA. This is a system API. | | nowCurrent<sup>9+</sup> | number | Yes | No | Battery current of the device, in unit of mA. **System API**: This is a system API. |
| remainingEnergy<sup>9+</sup> | number | Yes | No | Remaining battery capacity of the device, in unit of mAh. This is a system API.| | remainingEnergy<sup>9+</sup> | number | Yes | No | Remaining battery capacity of the device, in unit of mAh. **System API**: This is a system API.|
## BatteryPluggedType ## BatteryPluggedType
...@@ -41,10 +43,10 @@ Enumerates charger types. ...@@ -41,10 +43,10 @@ Enumerates charger types.
| Name | Value | Description | | Name | Value | Description |
| -------- | ---- | ----------------- | | -------- | ---- | ----------------- |
| NONE | 0 | Unknown type | | NONE | 0 | Unknown charger type. |
| AC | 1 | AC charger| | AC | 1 | AC charger.|
| USB | 2 | USB charger | | USB | 2 | USB charger. |
| WIRELESS | 3 | Wireless charger| | WIRELESS | 3 | Wireless charger.|
## BatteryChargeState ## BatteryChargeState
...@@ -82,14 +84,15 @@ Enumerates battery levels. ...@@ -82,14 +84,15 @@ Enumerates battery levels.
| Name | Value| Description | | Name | Value| Description |
| -------------- | ------ | ---------------------------- | | -------------- | ------ | ---------------------------- |
| LEVEL_NONE | 0 | Unknown battery level. |
| LEVEL_FULL | 1 | Full battery level. | | LEVEL_FULL | 1 | Full battery level. |
| LEVEL_HIGH | 2 | High battery level. | | LEVEL_HIGH | 2 | High battery level. |
| LEVEL_NORMAL | 3 | Normal battery level.| | LEVEL_NORMAL | 3 | Normal battery level.|
| LEVEL_LOW | 4 | Low battery level. | | LEVEL_LOW | 4 | Low battery level. |
| LEVEL_CRITICAL | 5 | Ultra-low battery level.| | LEVEL_WARNING | 5 | Alarm battery level.|
| LEVEL_CRITICAL | 6 | Ultra-low battery level.|
| LEVEL_SHUTDOWN | 7 | Power-down battery level.|
## CommonEventBatteryChangedCode<sup>9+</sup> ## CommonEventBatteryChangedKey<sup>9+</sup>
Enumerates keys for querying the additional information about the **COMMON_EVENT_BATTERY_CHANGED** event. Enumerates keys for querying the additional information about the **COMMON_EVENT_BATTERY_CHANGED** event.
...@@ -97,14 +100,12 @@ Enumerates keys for querying the additional information about the **COMMON_EVENT ...@@ -97,14 +100,12 @@ Enumerates keys for querying the additional information about the **COMMON_EVENT
| Name | Value| Description | | Name | Value| Description |
| -------------------- | ------ | -------------------------------------------------- | | -------------------- | ------ | -------------------------------------------------- |
| EXTRA_SOC | 0 | Remaining battery level in percentage. | | EXTRA_SOC | "soc" | Remaining battery level in percentage. |
| EXTRA_VOLTAGE | 1 | Battery voltage of the device. | | EXTRA_CHARGE_STATE | "chargeState" | Battery charging status of the device. |
| EXTRA_TEMPERATURE | 2 | Battery temperature of the device. | | EXTRA_HEALTH_STATE | "healthState" | Battery health status of the device. |
| EXTRA_HEALTH_STATE | 3 | Battery health status of the device. | | EXTRA_PLUGGED_TYPE | "pluggedType" | Type of the charger connected to the device. |
| EXTRA_PLUGGED_TYPE | 4 | Type of the charger connected to the device. | | EXTRA_VOLTAGE | "voltage" | Battery voltage of the device. |
| EXTRA_MAX_CURRENT | 5 | Maximum battery current of the device. | | EXTRA_TECHNOLOGY | "technology" | Battery technology of the device. |
| EXTRA_MAX_VOLTAGE | 6 | Maximum battery voltage of the device. | | EXTRA_TEMPERATURE | "temperature" | Battery temperature of the device. |
| EXTRA_CHARGE_STATE | 7 | Battery charging status of the device. | | EXTRA_PRESENT | "present" | Whether the battery is supported by the device or installed.|
| EXTRA_CHARGE_COUNTER | 8 | Number of battery charging times of the device. | | EXTRA_CAPACITY_LEVEL | "capacityLevel" | Battery level of the device. |
| EXTRA_PRESENT | 9 | Whether the battery is supported by the device or installed.|
| EXTRA_TECHNOLOGY | 10 | Battery technology of the device. |
...@@ -722,7 +722,7 @@ Subscribes to service status changes. ...@@ -722,7 +722,7 @@ Subscribes to service status changes.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | -------------------- | ---- | ------------------------------------------------------------ | | ------------- | -------------------- | ---- | ------------------------------------------------------------ |
| event | string | Yes | Event to subscribe to. The value is **distributedDataServiceDie**, which indicates a service status change event.| | event | string | Yes | Event to subscribe to. The value is **distributedDataServiceDie**, which indicates a service status change event.|
| deathCallback | Callback&lt;void&gt; | Yes | Callback invoked to service status changes. | | deathCallback | Callback&lt;void&gt; | Yes | Callback invoked to return service status changes. |
**Example** **Example**
...@@ -2847,7 +2847,7 @@ try { ...@@ -2847,7 +2847,7 @@ try {
### get ### get
get(key: string, callback: AsyncCallback<boolean | string| number | Uint8Array>): void get(key: string, callback: AsyncCallback&lt;boolean | string | number | Uint8Array&gt;): void
Obtains the value of the specified key. This API uses an asynchronous callback to return the result. Obtains the value of the specified key. This API uses an asynchronous callback to return the result.
...@@ -2898,7 +2898,7 @@ try { ...@@ -2898,7 +2898,7 @@ try {
### get ### get
get(key: string): Promise&lt;boolean | string| number | Uint8Array&gt; get(key: string): Promise&lt;boolean | string | number | Uint8Array&gt;
Obtains the value of the specified key. This API uses a promise to return the result. Obtains the value of the specified key. This API uses a promise to return the result.
...@@ -4849,7 +4849,7 @@ Before calling any method in **DeviceKVStore**, you must use [getKVStore](#getkv ...@@ -4849,7 +4849,7 @@ Before calling any method in **DeviceKVStore**, you must use [getKVStore](#getkv
### get ### get
get(key: string, callback: AsyncCallback<boolean | string| number | Uint8Array>): void get(key: string, callback: AsyncCallback&lt;boolean | string | number | Uint8Array&gt;): void
Obtains the value of the specified key for this device. This API uses an asynchronous callback to return the result. Obtains the value of the specified key for this device. This API uses an asynchronous callback to return the result.
...@@ -4900,7 +4900,7 @@ try { ...@@ -4900,7 +4900,7 @@ try {
### get ### get
get(key: string): Promise&lt;boolean | string| number | Uint8Array&gt; get(key: string): Promise&lt;boolean | string | number | Uint8Array&gt;
Obtains the value of the specified key for this device. This API uses a promise to return the result. Obtains the value of the specified key for this device. This API uses a promise to return the result.
...@@ -4952,7 +4952,7 @@ try { ...@@ -4952,7 +4952,7 @@ try {
### get ### get
get(deviceId: string, key: string, callback: AsyncCallback&lt;boolean|string|number|Uint8Array&gt;): void get(deviceId: string, key: string, callback: AsyncCallback&lt;boolean | string | number | Uint8Array&gt;): void
Obtains a string value that matches the specified device ID and key. This API uses an asynchronous callback to return the result. Obtains a string value that matches the specified device ID and key. This API uses an asynchronous callback to return the result.
...@@ -5004,7 +5004,7 @@ try { ...@@ -5004,7 +5004,7 @@ try {
### get ### get
get(deviceId: string, key: string): Promise&lt;boolean|string|number|Uint8Array&gt; get(deviceId: string, key: string): Promise&lt;boolean | string | number | Uint8Array&gt;
Obtains a string value that matches the specified device ID and key. This API uses a promise to return the result. Obtains a string value that matches the specified device ID and key. This API uses a promise to return the result.
......
...@@ -35,7 +35,7 @@ Enables a device administrator application based on the specified bundle name an ...@@ -35,7 +35,7 @@ Enables a device administrator application based on the specified bundle name an
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | --------------------------------------------------------------- | | ------- | --------------------------------------------------------------- |
...@@ -87,7 +87,7 @@ Enables a device administrator application for the specified user based on the s ...@@ -87,7 +87,7 @@ Enables a device administrator application for the specified user based on the s
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | --------------------------------------------------------------- | | ------- | --------------------------------------------------------------- |
...@@ -144,7 +144,7 @@ Enables a device administrator application based on the specified bundle name an ...@@ -144,7 +144,7 @@ Enables a device administrator application based on the specified bundle name an
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | --------------------------------------------------------------- | | ------- | --------------------------------------------------------------- |
...@@ -190,7 +190,7 @@ Disables a device common administrator application based on the specified bundle ...@@ -190,7 +190,7 @@ Disables a device common administrator application based on the specified bundle
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------------------- | | ------- | ----------------------------------------------------------------- |
...@@ -234,7 +234,7 @@ Disables a device common administrator application for the specified user based ...@@ -234,7 +234,7 @@ Disables a device common administrator application for the specified user based
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------------------- | | ------- | ----------------------------------------------------------------- |
...@@ -283,7 +283,7 @@ Disables a device common administrator application based on the specified bundle ...@@ -283,7 +283,7 @@ Disables a device common administrator application based on the specified bundle
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------------------- | | ------- | ----------------------------------------------------------------- |
...@@ -322,7 +322,7 @@ Disables a device super administrator application based on the specified bundle ...@@ -322,7 +322,7 @@ Disables a device super administrator application based on the specified bundle
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------------------- | | ------- | ----------------------------------------------------------------- |
...@@ -367,7 +367,7 @@ Disables a device super administrator application based on the specified bundle ...@@ -367,7 +367,7 @@ Disables a device super administrator application based on the specified bundle
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------------------- | | ------- | ----------------------------------------------------------------- |
...@@ -571,7 +571,7 @@ Sets the enterprise information of a device administrator application. This API ...@@ -571,7 +571,7 @@ Sets the enterprise information of a device administrator application. This API
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------- | | ------- | ----------------------------------------------------- |
...@@ -624,7 +624,7 @@ Sets the enterprise information of a device administrator application. This API ...@@ -624,7 +624,7 @@ Sets the enterprise information of a device administrator application. This API
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------- | | ------- | ----------------------------------------------------- |
...@@ -665,7 +665,7 @@ Obtains the enterprise information of a device administrator application. This A ...@@ -665,7 +665,7 @@ Obtains the enterprise information of a device administrator application. This A
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------- | | ------- | ----------------------------------------------------- |
...@@ -712,7 +712,7 @@ Obtains the enterprise information of a device administrator application. This A ...@@ -712,7 +712,7 @@ Obtains the enterprise information of a device administrator application. This A
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------- | | ------- | ----------------------------------------------------- |
...@@ -755,7 +755,7 @@ Subscribes to system management events. This API uses an asynchronous callback t ...@@ -755,7 +755,7 @@ Subscribes to system management events. This API uses an asynchronous callback t
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
|ID| Error Message | |ID| Error Message |
| ------- | ----------------------------------------------------- | | ------- | ----------------------------------------------------- |
...@@ -804,7 +804,7 @@ Subscribes to system management events. This API uses a promise to return the re ...@@ -804,7 +804,7 @@ Subscribes to system management events. This API uses a promise to return the re
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------- | | ------- | ----------------------------------------------------- |
...@@ -847,7 +847,7 @@ Unsubscribes from system management events. This API uses an asynchronous callba ...@@ -847,7 +847,7 @@ Unsubscribes from system management events. This API uses an asynchronous callba
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------- | | ------- | ----------------------------------------------------- |
...@@ -896,7 +896,7 @@ Unsubscribes from system management events. This API uses an asynchronous callba ...@@ -896,7 +896,7 @@ Unsubscribes from system management events. This API uses an asynchronous callba
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ----------------------------------------------------- | | ------- | ----------------------------------------------------- |
......
...@@ -34,7 +34,7 @@ Sets the system time. This API uses an asynchronous callback to return the resul ...@@ -34,7 +34,7 @@ Sets the system time. This API uses an asynchronous callback to return the resul
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
...@@ -82,7 +82,7 @@ Sets the system time. This API uses a promise to return the result. ...@@ -82,7 +82,7 @@ Sets the system time. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
......
# @ohos.enterprise.deviceControl (Device Control Management)
The **deviceControl** module provides APIs for device control, which can only be called by device administrator applications.
> **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.
## Modules to Import
```js
import deviceControl from '@ohos.enterprise.deviceControl'
```
## deviceControl.resetFactory
resetFactory(admin: Want, callback: AsyncCallback\<void>): void
Restores factory settings. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_RESET_DEVICE
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the setting is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**Example:**
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
deviceControl.resetFactory(wantTemp, (error) => {
if (error) {
console.log("error code:" + error.code + " error message:" + error.message);
}
})
```
## deviceControl.resetFactory
resetFactory(admin: Want): Promise\<void>
Restores factory settings. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_RESET_DEVICE
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
**Return value**
| Type | Description |
| ----- | ----------------------------------- |
| Promise\<void> | Promise that returns no value.|
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**Example:**
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
deviceControl.resetFactory(wantTemp).then(() => {
}).catch((error) => {
console.log("error code:" + error.code + " error message:" + error.message);
})
```
...@@ -33,7 +33,7 @@ Obtains the device serial number. This API uses an asynchronous callback to retu ...@@ -33,7 +33,7 @@ Obtains the device serial number. This API uses an asynchronous callback to retu
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
...@@ -82,7 +82,7 @@ Obtains the device serial number. This API uses a promise to return the result. ...@@ -82,7 +82,7 @@ Obtains the device serial number. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
...@@ -124,7 +124,7 @@ Obtains the device version number. This API uses an asynchronous callback to ret ...@@ -124,7 +124,7 @@ Obtains the device version number. This API uses an asynchronous callback to ret
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
...@@ -173,7 +173,7 @@ Obtains the device version number. This API uses a promise to return the result. ...@@ -173,7 +173,7 @@ Obtains the device version number. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
...@@ -215,7 +215,7 @@ Obtains the device name. This API uses an asynchronous callback to return the re ...@@ -215,7 +215,7 @@ Obtains the device name. This API uses an asynchronous callback to return the re
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
...@@ -264,7 +264,7 @@ Obtains the device name. This API uses a promise to return the result. ...@@ -264,7 +264,7 @@ Obtains the device name. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message | | ID| Error Message |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
......
...@@ -17,7 +17,7 @@ import fileAccess from '@ohos.file.fileAccess'; ...@@ -17,7 +17,7 @@ import fileAccess from '@ohos.file.fileAccess';
getFileAccessAbilityInfo( ) : Promise&lt;Array&lt;Want&gt;&gt; getFileAccessAbilityInfo( ) : Promise&lt;Array&lt;Want&gt;&gt;
Obtains information about all wants with **extension** set to **fileAcesss** in the system. A want is a basic communication component used to start services. This API uses a promise to return the result. Obtains information about all wants with **extension** set to **fileAccess** in the system. A want is a basic communication component used to start services. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService **System capability**: SystemCapability.FileManagement.UserFileService
...@@ -25,9 +25,9 @@ Obtains information about all wants with **extension** set to **fileAcesss** in ...@@ -25,9 +25,9 @@ Obtains information about all wants with **extension** set to **fileAcesss** in
**Return value** **Return value**
| Type| Description| | Type| Description|
| --- | -- | | --- | -- |
| Promise&lt;Array&lt;Want&gt;&gt; | Promise used to return the **want** information obtained.| | Promise&lt;Array&lt;Want&gt;&gt; | Promise used to return the **want** information obtained.|
**Example** **Example**
...@@ -47,7 +47,7 @@ Obtains information about all wants with **extension** set to **fileAcesss** in ...@@ -47,7 +47,7 @@ Obtains information about all wants with **extension** set to **fileAcesss** in
getFileAccessAbilityInfo(callback: AsyncCallback&lt;Array&lt;Want&gt;&gt;): void; getFileAccessAbilityInfo(callback: AsyncCallback&lt;Array&lt;Want&gt;&gt;): void;
Obtains information about all wants with **extension** set to **fileAcesss** in the system. A want is a basic communication component used to start services. This API uses an asynchronous callback to return the result. Obtains information about all wants with **extension** set to **fileAccess** in the system. A want is a basic communication component used to start services. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService **System capability**: SystemCapability.FileManagement.UserFileService
...@@ -55,9 +55,9 @@ Obtains information about all wants with **extension** set to **fileAcesss** in ...@@ -55,9 +55,9 @@ Obtains information about all wants with **extension** set to **fileAcesss** in
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| callback | AsyncCallback&lt;Array&lt;Want&gt;&gt; | Yes| Promise used to return the **want** information obtained.| | callback | AsyncCallback&lt;Array&lt;Want&gt;&gt; | Yes| Promise used to return the **want** information obtained.|
**Example** **Example**
...@@ -89,16 +89,16 @@ Synchronously creates a **Helper** object to connect to the specified wants. The ...@@ -89,16 +89,16 @@ Synchronously creates a **Helper** object to connect to the specified wants. The
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| context | Context | Yes| Context of the ability.| | context | Context | Yes| Context of the ability.|
| wants | Array&lt;Want&gt; | Yes| Wants to connect.| | wants | Array&lt;Want&gt; | Yes| Wants to connect.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| --- | -- | | --- | -- |
| FileAccessHelper | **Helper** object created.| | FileAccessHelper | **Helper** object created.|
**Example** **Example**
...@@ -114,7 +114,7 @@ Synchronously creates a **Helper** object to connect to the specified wants. The ...@@ -114,7 +114,7 @@ Synchronously creates a **Helper** object to connect to the specified wants. The
}, },
] ]
try { try {
// this.context is passed by MainAbility. // this.context is passed by EntryAbility.
fileAccessHelper = fileAccess.createFileAccessHelper(this.context, wantInfos); fileAccessHelper = fileAccess.createFileAccessHelper(this.context, wantInfos);
if (!fileAccessHelper) if (!fileAccessHelper)
console.error("createFileAccessHelper interface returns an undefined object"); console.error("createFileAccessHelper interface returns an undefined object");
...@@ -136,15 +136,15 @@ Synchronously creates a **Helper** object to connect to all file management serv ...@@ -136,15 +136,15 @@ Synchronously creates a **Helper** object to connect to all file management serv
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| context | Context | Yes| Context of the ability.| | context | Context | Yes| Context of the ability.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| --- | -- | | --- | -- |
| FileAccessHelper | **Helper** object created.| | FileAccessHelper | **Helper** object created.|
**Example** **Example**
...@@ -153,7 +153,7 @@ Synchronously creates a **Helper** object to connect to all file management serv ...@@ -153,7 +153,7 @@ Synchronously creates a **Helper** object to connect to all file management serv
let fileAccesssHelperAllServer = null; let fileAccesssHelperAllServer = null;
// Create a Helper object to interact with all file management services configured with fileAccess in the system. // Create a Helper object to interact with all file management services configured with fileAccess in the system.
try { try {
// this.context is passed by MainAbility. // this.context is passed by EntryAbility.
fileAccesssHelperAllServer = fileAccess.createFileAccessHelper(this.context); fileAccesssHelperAllServer = fileAccess.createFileAccessHelper(this.context);
if (!fileAccesssHelperAllServer) if (!fileAccesssHelperAllServer)
console.error("createFileAccessHelper interface returns an undefined object"); console.error("createFileAccessHelper interface returns an undefined object");
...@@ -167,8 +167,7 @@ Synchronously creates a **Helper** object to connect to all file management serv ...@@ -167,8 +167,7 @@ Synchronously creates a **Helper** object to connect to all file management serv
getRoots( ) : Promise&lt;RootIterator&gt; getRoots( ) : Promise&lt;RootIterator&gt;
Obtains information about the device root nodes of the file management service type connected to the **Helper** object. This API uses a promise to return a **RootIterator** object, which Obtains information about the device root nodes of the file management service type connected to the **Helper** object. This API uses a promise to return a **RootIterator** object, which returns [RootInfo](#rootinfo) by using [next()](#rootiteratornext).
returns [RootInfo](#rootinfo) by using [next()](#rootiteratornext).
**System capability**: SystemCapability.FileManagement.UserFileService **System capability**: SystemCapability.FileManagement.UserFileService
...@@ -176,9 +175,9 @@ returns [RootInfo](#rootinfo) by using [next()](#rootiteratornext). ...@@ -176,9 +175,9 @@ returns [RootInfo](#rootinfo) by using [next()](#rootiteratornext).
**Return value** **Return value**
| Type| Description| | Type| Description|
| --- | -- | | --- | -- |
| Promise&lt;RootIterator&gt; | Promise used to return the **RootIterator** object obtained.| | Promise&lt;RootIterator&gt; | Promise used to return the **RootIterator** object obtained.|
**Example** **Example**
...@@ -211,8 +210,7 @@ returns [RootInfo](#rootinfo) by using [next()](#rootiteratornext). ...@@ -211,8 +210,7 @@ returns [RootInfo](#rootinfo) by using [next()](#rootiteratornext).
getRoots(callback:AsyncCallback&lt;RootIterator&gt;) : void; getRoots(callback:AsyncCallback&lt;RootIterator&gt;) : void;
Obtains information about the device root nodes of the file management service type connected to the **Helper** object. This API uses an asynchronous callback to return the result. Obtains information about the device root nodes of the file management service type connected to the **Helper** object. This API uses an asynchronous callback to return the result. The callback has a **RootIterator** object, which returns [RootInfo](#rootinfo) through [next()](#rootiteratornext).
The callback has a **RootIterator** object, which returns [RootInfo](#rootinfo) through [next()](#rootiteratornext).
**System capability**: SystemCapability.FileManagement.UserFileService **System capability**: SystemCapability.FileManagement.UserFileService
...@@ -220,9 +218,9 @@ The callback has a **RootIterator** object, which returns [RootInfo](#rootinfo) ...@@ -220,9 +218,9 @@ The callback has a **RootIterator** object, which returns [RootInfo](#rootinfo)
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| callback | AsyncCallback&lt;RootIterator&gt; | Yes| Promise used to return the **RootIterator** object obtained.| | callback | AsyncCallback&lt;RootIterator&gt; | Yes| Promise used to return the **RootIterator** object obtained.|
**Example** **Example**
...@@ -263,16 +261,16 @@ Synchronously obtains the **FileIterator** object of the first-level files (file ...@@ -263,16 +261,16 @@ Synchronously obtains the **FileIterator** object of the first-level files (file
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | -- | -- | | --- | --- | -- | -- |
| filter | Filter | No| **Filter** object. | | filter | Filter | No| **Filter** object. |
**Return value** **Return value**
| Type| Description| | Type| Description|
| --- | -- | | --- | -- |
| FileIterator | **FileIterator** object obtained.| | FileIterator | **FileIterator** object obtained.|
**Example** **Example**
...@@ -314,15 +312,15 @@ Recursively obtains the **FileIterator** object of the files matching the condit ...@@ -314,15 +312,15 @@ Recursively obtains the **FileIterator** object of the files matching the condit
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | -- | -- | | --- | --- | -- | -- |
| filter | Filter | No| **Filter** object. | | filter | Filter | No| **Filter** object. |
**Return value** **Return value**
| Type| Description| | Type| Description|
| --- | -- | | --- | -- |
| FileIterator | **FileIterator** object obtained.| | FileIterator | **FileIterator** object obtained.|
**Example** **Example**
...@@ -364,15 +362,15 @@ Synchronously obtains the **FileIterator** object of the next-level files (file ...@@ -364,15 +362,15 @@ Synchronously obtains the **FileIterator** object of the next-level files (file
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | -- | -- | | --- | --- | -- | -- |
| filter | Filter | No| **Filter** object. | | filter | Filter | No| **Filter** object. |
**Return value** **Return value**
| Type| Description| | Type| Description|
| --- | -- | | --- | -- |
| FileIterator | **FileIterator** object obtained.| | FileIterator | **FileIterator** object obtained.|
**Example** **Example**
...@@ -414,16 +412,16 @@ Recursively obtains the **FileIterator** object of the files matching the condit ...@@ -414,16 +412,16 @@ Recursively obtains the **FileIterator** object of the files matching the condit
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | -- | -- | | --- | --- | -- | -- |
| filter | Filter | No| **Filter** object. | | filter | Filter | No| **Filter** object. |
**Return value** **Return value**
| Type| Description| | Type| Description|
| --- | -- | | --- | -- |
| FileIterator | **FileIterator** object obtained.| | FileIterator | **FileIterator** object obtained.|
**Example** **Example**
...@@ -465,10 +463,10 @@ Creates a file in a directory. This API uses a promise to return the result. ...@@ -465,10 +463,10 @@ Creates a file in a directory. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| uri | string | Yes| URI of the parent directory for the file to create.| | uri | string | Yes| URI of the parent directory for the file to create.|
| displayName | string | Yes| Name of the file to create. By default, the name of a local file must contain the file name extension.| | displayName | string | Yes| Name of the file to create. By default, the name of a local file must contain the file name extension.|
**Return value** **Return value**
...@@ -510,11 +508,11 @@ Creates a file in a directory. This API uses an asynchronous callback to return ...@@ -510,11 +508,11 @@ Creates a file in a directory. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| uri | string | Yes| URI of the parent directory for the file to create.| | uri | string | Yes| URI of the parent directory for the file to create.|
| displayName | string | Yes| Name of the file to create. By default, the name of a local file must contain the file name extension.| | displayName | string | Yes| Name of the file to create. By default, the name of a local file must contain the file name extension.|
| callback | AsyncCallback&lt;string&gt; | Yes| Promise used to return the URI of the file created.| | callback | AsyncCallback&lt;string&gt; | Yes| Promise used to return the URI of the file created.|
**Example** **Example**
...@@ -550,10 +548,10 @@ Creates a folder in a directory. This API uses a promise to return the result. ...@@ -550,10 +548,10 @@ Creates a folder in a directory. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| parentUri | string | Yes| URI of the parent directory for the folder to create.| | parentUri | string | Yes| URI of the parent directory for the folder to create.|
| displayName | string | Yes| Name of the folder to create.| | displayName | string | Yes| Name of the folder to create.|
**Return value** **Return value**
...@@ -595,11 +593,11 @@ Creates a folder in a directory. This API uses an asynchronous callback to retur ...@@ -595,11 +593,11 @@ Creates a folder in a directory. This API uses an asynchronous callback to retur
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| parentUri | string | Yes| URI of the parent directory for the folder to create.| | parentUri | string | Yes| URI of the parent directory for the folder to create.|
| displayName | string | Yes| Name of the folder to create.| | displayName | string | Yes| Name of the folder to create.|
| callback | AsyncCallback&lt;string&gt; | Yes| Promise used to return the URI of the folder created.| | callback | AsyncCallback&lt;string&gt; | Yes| Promise used to return the URI of the folder created.|
**Example** **Example**
...@@ -635,16 +633,16 @@ Opens a file. This API uses a promise to return the result. ...@@ -635,16 +633,16 @@ Opens a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| uri | string | Yes| URI of the file to open.| | uri | string | Yes| URI of the file to open.|
| flags | [OPENFLAGS](#openflags) | Yes| File open mode.| | flags | [OPENFLAGS](#openflags) | Yes| File open mode.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| --- | -- | | --- | -- |
| Promise&lt;number&gt; | Promise used to return the handle to the file opened.| | Promise&lt;number&gt; | Promise used to return the file descriptor of the file opened.|
**Example** **Example**
...@@ -673,11 +671,11 @@ Opens a file. This API uses an asynchronous callback to return the result. ...@@ -673,11 +671,11 @@ Opens a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| uri | string | Yes| URI of the file to open.| | uri | string | Yes| URI of the file to open.|
| flags | [OPENFLAGS](#openflags) | Yes| File open mode.| | flags | [OPENFLAGS](#openflags) | Yes| File open mode.|
| callback | AsyncCallback&lt;number&gt; | Yes| Promise used to return the handle to the file opened.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the file descriptor of the file opened.|
**Example** **Example**
...@@ -712,9 +710,9 @@ Deletes a file or folder. This API uses a promise to return the result. ...@@ -712,9 +710,9 @@ Deletes a file or folder. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| uri | string | Yes| URI of the file or folder to delete.| | uri | string | Yes| URI of the file or folder to delete.|
**Return value** **Return value**
...@@ -751,10 +749,10 @@ Deletes a file or folder. This API uses an asynchronous callback to return the r ...@@ -751,10 +749,10 @@ Deletes a file or folder. This API uses an asynchronous callback to return the r
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| uri | string | Yes| URI of the file or folder to delete.| | uri | string | Yes| URI of the file or folder to delete.|
| callback | AsyncCallback&lt;number&gt; | Yes| Promise used to return the result.| | callback | AsyncCallback&lt;number&gt; | Yes| Promise used to return the result.|
**Example** **Example**
...@@ -789,10 +787,10 @@ Moves a file or folder. This API uses a promise to return the result. ...@@ -789,10 +787,10 @@ Moves a file or folder. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| sourceFile | string | Yes| URI of the file or folder to move.| | sourceFile | string | Yes| URI of the file or folder to move.|
| destFile | string | Yes| URI of the folder to which the file or folder will be moved.| | destFile | string | Yes| URI of the folder to which the file or folder will be moved.|
**Return value** **Return value**
...@@ -829,11 +827,11 @@ Moves a file or folder. This API uses an asynchronous callback to return the res ...@@ -829,11 +827,11 @@ Moves a file or folder. This API uses an asynchronous callback to return the res
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| sourceFile | string | Yes| URI of the file or folder to move.| | sourceFile | string | Yes| URI of the file or folder to move.|
| destFile | string | Yes| URI of the folder to which the file or folder will be moved.| | destFile | string | Yes| URI of the folder to which the file or folder will be moved.|
| callback | AsyncCallback&lt;string&gt; | Yes| Promise used to return the URI of the file or folder in the destination directory.| | callback | AsyncCallback&lt;string&gt; | Yes| Promise used to return the URI of the file or folder in the destination directory.|
**Example** **Example**
...@@ -869,10 +867,10 @@ Renames a file or folder. This API uses a promise to return the result. ...@@ -869,10 +867,10 @@ Renames a file or folder. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| uri | string | Yes| URI of the file or folder to rename.| | uri | string | Yes| URI of the file or folder to rename.|
| displayName | string | Yes| New name of the file or folder, which can contain the file name extension.| | displayName | string | Yes| New name of the file or folder, which can contain the file name extension.|
**Return value** **Return value**
...@@ -908,11 +906,11 @@ Renames a file or folder. This API uses an asynchronous callback to return the r ...@@ -908,11 +906,11 @@ Renames a file or folder. This API uses an asynchronous callback to return the r
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| uri | string | Yes| URI of the file or folder to rename.| | uri | string | Yes| URI of the file or folder to rename.|
| displayName | string | Yes| New name of the file or folder, which can contain the file name extension.| | displayName | string | Yes| New name of the file or folder, which can contain the file name extension.|
| callback | AsyncCallback&lt;string&gt; | Yes| Promise used to return the URI of the renamed file or folder.| | callback | AsyncCallback&lt;string&gt; | Yes| Promise used to return the URI of the renamed file or folder.|
**Example** **Example**
...@@ -947,9 +945,9 @@ Checks whether a file or folder exists. This API uses a promise to return the re ...@@ -947,9 +945,9 @@ Checks whether a file or folder exists. This API uses a promise to return the re
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| sourceFileUri | string | Yes| URI of the file or folder.| | sourceFileUri | string | Yes| URI of the file or folder.|
**Return value** **Return value**
...@@ -988,10 +986,10 @@ Checks whether a file or folder exists. This API uses an asynchronous callback t ...@@ -988,10 +986,10 @@ Checks whether a file or folder exists. This API uses an asynchronous callback t
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| sourceFileUri | string | Yes| URI of the file or folder.| | sourceFileUri | string | Yes| URI of the file or folder.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Promise used to return the result.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Promise used to return the result.|
**Example** **Example**
......
...@@ -278,7 +278,7 @@ Obtains the mouse pointer style. This API uses an asynchronous callback to retur ...@@ -278,7 +278,7 @@ Obtains the mouse pointer style. This API uses an asynchronous callback to retur
import window from '@ohos.window'; import window from '@ohos.window';
window.getTopWindow((error, win) => { window.getTopWindow((error, win) => {
win.getProperties((error, properties) => { win.getWindowProperties((error, properties) => {
let windowId = properties.id; let windowId = properties.id;
if (windowId < 0) { if (windowId < 0) {
console.log(`Invalid windowId`); console.log(`Invalid windowId`);
...@@ -321,7 +321,7 @@ Obtains the mouse pointer style. This API uses a promise to return the result. ...@@ -321,7 +321,7 @@ Obtains the mouse pointer style. This API uses a promise to return the result.
import window from '@ohos.window'; import window from '@ohos.window';
window.getTopWindow((error, win) => { window.getTopWindow((error, win) => {
win.getProperties((error, properties) => { win.getWindowProperties((error, properties) => {
let windowId = properties.id; let windowId = properties.id;
if (windowId < 0) { if (windowId < 0) {
console.log(`Invalid windowId`); console.log(`Invalid windowId`);
...@@ -360,7 +360,7 @@ Sets the mouse pointer style. This API uses an asynchronous callback to return t ...@@ -360,7 +360,7 @@ Sets the mouse pointer style. This API uses an asynchronous callback to return t
import window from '@ohos.window'; import window from '@ohos.window';
window.getTopWindow((error, win) => { window.getTopWindow((error, win) => {
win.getProperties((error, properties) => { win.getWindowProperties((error, properties) => {
let windowId = properties.id; let windowId = properties.id;
if (windowId < 0) { if (windowId < 0) {
console.log(`Invalid windowId`); console.log(`Invalid windowId`);
...@@ -398,7 +398,7 @@ Sets the mouse pointer style. This API uses a promise to return the result. ...@@ -398,7 +398,7 @@ Sets the mouse pointer style. This API uses a promise to return the result.
import window from '@ohos.window'; import window from '@ohos.window';
window.getTopWindow((error, win) => { window.getTopWindow((error, win) => {
win.getProperties((error, properties) => { win.getWindowProperties((error, properties) => {
let windowId = properties.id; let windowId = properties.id;
if (windowId < 0) { if (windowId < 0) {
console.log(`Invalid windowId`); console.log(`Invalid windowId`);
......
...@@ -286,95 +286,6 @@ Uploads files. This API uses an asynchronous callback to return the result. ...@@ -286,95 +286,6 @@ Uploads files. This API uses an asynchronous callback to return the result.
}); });
``` ```
## request.upload<sup>(deprecated)</sup>
upload(context: BaseContext, config: UploadConfig): Promise&lt;UploadTask&gt;
Uploads files. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 9 and is deprecated since API version 9. You are advised to use [request.uploadFile<sup>9+</sup>](#requestuploadfile9).
**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.|
| config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[UploadTask](#uploadtask)&gt; | Promise used to return the **UploadTask** object.|
**Example**
```js
let uploadTask;
let uploadConfig = {
url: 'http://patch',
header: { key1: "value1", key2: "value2" },
method: "POST",
files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }],
data: [{ name: "name123", value: "123" }],
};
request.upload(globalThis.abilityContext, uploadConfig).then((data) => {
uploadTask = data;
}).catch((err) => {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
});
```
## request.upload<sup>(deprecated)</sup>
upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback&lt;UploadTask&gt;): void
Uploads files. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [request.uploadFile<sup>9+</sup>](#requestuploadfile9-1).
**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.|
| config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.|
| callback | AsyncCallback&lt;[UploadTask](#uploadtask)&gt; | Yes| Callback used to return the **UploadTask** object.|
**Example**
```js
let uploadTask;
let uploadConfig = {
url: 'http://patch',
header: { key1: "value1", key2: "value2" },
method: "POST",
files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }],
data: [{ name: "name123", value: "123" }],
};
request.upload(globalThis.abilityContext, uploadConfig, (err, data) => {
if (err) {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
return;
}
uploadTask = data;
});
```
## UploadTask ## UploadTask
Implements file uploads. Before using any APIs of this class, you must obtain an **UploadTask** object through [request.uploadFile<sup>9+</sup>](#requestuploadfile9) in promise mode or [request.uploadFile<sup>9+</sup>](#requestuploadfile9-1) in callback mode. Implements file uploads. Before using any APIs of this class, you must obtain an **UploadTask** object through [request.uploadFile<sup>9+</sup>](#requestuploadfile9) in promise mode or [request.uploadFile<sup>9+</sup>](#requestuploadfile9-1) in callback mode.
...@@ -398,7 +309,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -398,7 +309,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (upload progress).| | type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (upload progress).|
| callback | function | Yes| Callback for the upload progress event.| | callback | function | Yes| Callback for the upload progress event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -432,7 +343,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -432,7 +343,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
| type | string | Yes| Type of the event to subscribe to. The value is **'headerReceive'** (response header).| | type | string | Yes| Type of the event to subscribe to. The value is **'headerReceive'** (response header).|
| callback | function | Yes| Callback for the HTTP Response Header event.| | callback | function | Yes| Callback for the HTTP Response Header event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -465,7 +376,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -465,7 +376,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.| | type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| callback | Callback&lt;Array&lt;TaskState&gt;&gt; | Yes| Callback used to return the result.| | callback | Callback&lt;Array&lt;TaskState&gt;&gt; | Yes| Callback used to return the result.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -507,7 +418,7 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -507,7 +418,7 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).|
| callback | function | No| Callback for the upload progress event.| | callback | function | No| Callback for the upload progress event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -541,7 +452,7 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -541,7 +452,7 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).|
| callback | function | No| Callback for the HTTP Response Header event.| | callback | function | No| Callback for the HTTP Response Header event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -573,7 +484,7 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -573,7 +484,7 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.| | type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| callback | Callback&lt;Array&lt;TaskState&gt;&gt; | No| Callback used to return the result.| | callback | Callback&lt;Array&lt;TaskState&gt;&gt; | No| Callback used to return the result.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -952,82 +863,6 @@ Downloads files. This API uses an asynchronous callback to return the result. ...@@ -952,82 +863,6 @@ Downloads files. This API uses an asynchronous callback to return the result.
}); });
``` ```
## request.download<sup>(deprecated)</sup>
download(context: BaseContext, config: DownloadConfig): Promise&lt;DownloadTask&gt;
Downloads files. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 9 and is deprecated since API version 9. You are advised to use [request.downloadFile<sup>9+</sup>](#requestdownloadfile9).
**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.|
| config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[DownloadTask](#downloadtask)&gt; | Promise used to return the result.|
**Example**
```js
let downloadTask;
request.download(globalThis.abilityContext, { url: 'https://xxxx/xxxx.hap' }).then((data) => {
downloadTask = data;
}).catch((err) => {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
})
```
## request.download<sup>(deprecated)</sup>
download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback&lt;DownloadTask&gt;): void;
Downloads files. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [request.downloadFile<sup>9+</sup>](#requestdownloadfile9-1).
**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.|
| config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.|
| callback | AsyncCallback&lt;[DownloadTask](#downloadtask)&gt; | Yes| Callback used to return the result.|
**Example**
```js
let downloadTask;
request.download(globalThis.abilityContext, { url: 'https://xxxx/xxxxx.hap',
filePath: 'xxx/xxxxx.hap'}, (err, data) => {
if (err) {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
return;
}
downloadTask = data;
});
```
## DownloadTask ## DownloadTask
Implements file downloads. Before using any APIs of this class, you must obtain a **DownloadTask** object through [request.downloadFile<sup>9+</sup>](#requestdownloadfile9) in promise mode or [request.downloadFile<sup>9+</sup>](#requestdownloadfile9-1) in callback mode. Implements file downloads. Before using any APIs of this class, you must obtain a **DownloadTask** object through [request.downloadFile<sup>9+</sup>](#requestdownloadfile9) in promise mode or [request.downloadFile<sup>9+</sup>](#requestdownloadfile9-1) in callback mode.
...@@ -1050,7 +885,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -1050,7 +885,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).| | type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).|
| callback | function | Yes| Callback for the download progress event.| | callback | function | Yes| Callback for the download progress event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -1084,7 +919,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re ...@@ -1084,7 +919,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (download progress).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (download progress).|
| callback | function | No| Callback for the download progress event.| | callback | function | No| Callback for the download progress event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -1172,7 +1007,7 @@ Subscribes to the download task failure event. This API uses an asynchronous cal ...@@ -1172,7 +1007,7 @@ Subscribes to the download task failure event. This API uses an asynchronous cal
| type | string | Yes| Type of the event to subscribe to. The value is **'fail'** (download failure).| | type | string | Yes| Type of the event to subscribe to. The value is **'fail'** (download failure).|
| callback | function | Yes| Callback for the download task failure event.| | callback | function | Yes| Callback for the download task failure event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -1205,7 +1040,7 @@ Unsubscribes from the download task failure event. This API uses an asynchronous ...@@ -1205,7 +1040,7 @@ Unsubscribes from the download task failure event. This API uses an asynchronous
| type | string | Yes| Type of the event to unsubscribe from. The value is **'fail'** (download failure).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'fail'** (download failure).|
| callback | function | No| Callback for the download task failure event.| | callback | function | No| Callback for the download task failure event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -1265,7 +1100,7 @@ Deletes this download task. This API uses an asynchronous callback to return the ...@@ -1265,7 +1100,7 @@ Deletes this download task. This API uses an asynchronous callback to return the
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the task deletion result. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the task deletion result.|
**Example** **Example**
......
...@@ -47,7 +47,7 @@ Provides data items for setting the display effects. ...@@ -47,7 +47,7 @@ Provides data items for setting the display effects.
| ANIMATOR_DURATION_SCALE | string | Yes | Yes | Scale factor for the animation duration. This affects the start delay and duration of all such animations.<br>If the value is **0**, the animation ends immediately. The default value is **1**.| | ANIMATOR_DURATION_SCALE | string | Yes | Yes | Scale factor for the animation duration. This affects the start delay and duration of all such animations.<br>If the value is **0**, the animation ends immediately. The default value is **1**.|
| TRANSITION_ANIMATION_SCALE | string | Yes | Yes | Scale factor for transition animations.<br>The value **0** indicates that the transition animations are disabled. | | TRANSITION_ANIMATION_SCALE | string | Yes | Yes | Scale factor for transition animations.<br>The value **0** indicates that the transition animations are disabled. |
| WINDOW_ANIMATION_SCALE | string | Yes | Yes | Scale factor for normal window animations.<br>The value **0** indicates that window animations are disabled. | | WINDOW_ANIMATION_SCALE | string | Yes | Yes | Scale factor for normal window animations.<br>The value **0** indicates that window animations are disabled. |
| DISPLAY_INVERSION_STATUS | string | Yes | Yes | Whether display color inversion is enabled.<br>**1**: Display color inversion is enabled.<br>**0**: Display color inversion is disabled. | | DISPLAY_INVERSION_STATUS | string | Yes | Yes | Whether display color inversion is enabled.<br>**1**: Display color inversion is enabled.<br>**0**: Display color inversion is disabled.|
## general ## general
...@@ -185,121 +185,6 @@ Provides data items for setting wireless network information. ...@@ -185,121 +185,6 @@ Provides data items for setting wireless network information.
| WIFI_STATUS | string | Yes | Yes | Whether Wi-Fi is available.<br>**true**: Wi-Fi is available.<br>**false**: Wi-Fi is unavailable.| | WIFI_STATUS | string | Yes | Yes | Whether Wi-Fi is available.<br>**true**: Wi-Fi is available.<br>**false**: Wi-Fi is unavailable.|
| WIFI_WATCHDOG_STATUS | string | Yes | Yes | Whether Wi-Fi watchdog is available.<br>**true**: Wi-Fi watchdog is available.<br>**false**: Wi-Fi watchdog is unavailable.| | WIFI_WATCHDOG_STATUS | string | Yes | Yes | Whether Wi-Fi watchdog is available.<br>**true**: Wi-Fi watchdog is available.<br>**false**: Wi-Fi watchdog is unavailable.|
## setting.getURI
getURI(name: string, callback: AsyncCallback\<object>): void
Obtains the URI of a data item. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
| callback | AsyncCallback\<object> | Yes | Callback used to obtain the URI of the data item. |
**Example**
```js
settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS, (uri) => {
console.log(`callback:uri -> ${JSON.stringify(uri)}`)
})
```
## setting.getURI
getURI(name: string): Promise\<object>
Obtains the URI of a data item. This API uses a promise to return the result.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
**Return value**
| Type | Description |
| ---------------- | ------------------------------------ |
| Promise\<object> | Promise used to return the URI of the data item.|
**Example**
```js
settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS).then((uri) => {
console.log(`promise:uri -> ${JSON.stringify(uri)}`)
})
```
## setting.getValue
getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback\<object>): void
Obtains the value of a data item in the database. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br> - Existing data items in the database<br>- Custom data items|
| callback | AsyncCallback\<object> | Yes | Callback used to return the value of the data item. |
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility';
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, (err, value) => {
if (err) {
console.error(`Failed to get the setting. ${err.message} `);
return;
}
console.log(`callback:value -> ${JSON.stringify(value)}`)
});
```
## setting.getValue
getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise\<object>
Obtains the value of a data item in the database. This API uses a promise to return the result.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br> - Existing data items in the database<br>- Custom data items|
**Return value**
| Type | Description |
| ---------------- | ----------------------------------- |
| Promise\<object> | Promise used to return the value of the data item.|
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility';
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value) => {
console.log(`promise:value -> ${JSON.stringify(value)}`)
});
```
## settings.setValue ## settings.setValue
...@@ -325,9 +210,11 @@ Sets the value for a data item. This API uses an asynchronous callback to return ...@@ -325,9 +210,11 @@ Sets the value for a data item. This API uses an asynchronous callback to return
```js ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update the value of the data item.) // Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri); let helper = featureAbility.acquireDataAbilityHelper(uri);
// @ts-ignore
// The value of the data item is a string.
settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', (status) => { settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', (status) => {
console.log('Callback return whether value is set.'); console.log('Callback return whether value is set.');
}); });
...@@ -365,6 +252,8 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -365,6 +252,8 @@ import featureAbility from '@ohos.ability.featureAbility';
// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update the value of the data item.) // Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update the value of the data item.)
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri); let helper = featureAbility.acquireDataAbilityHelper(uri);
// @ts-ignore
// The value of the data item is a string.
settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100').then((status) => { settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100').then((status) => {
console.log('Callback return whether value is set.'); console.log('Callback return whether value is set.');
}); });
...@@ -500,12 +389,154 @@ Obtains the URI of a data item. ...@@ -500,12 +389,154 @@ Obtains the URI of a data item.
let urivar = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); let urivar = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
``` ```
## settings.getValueSync<sup>8+</sup> ## setting.getURI<sup>(deprecated)</sup>
getURI(name: string, callback: AsyncCallback\<object>): void
Obtains the URI of a data item. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
| callback | AsyncCallback\<object> | Yes | Callback used to obtain the URI of the data item. |
**Example**
```js
settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS, (uri) => {
console.log(`callback:uri -> ${JSON.stringify(uri)}`)
})
```
## setting.getURI<sup>(deprecated)</sup>
getURI(name: string): Promise\<object>
Obtains the URI of a data item. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
**Return value**
| Type | Description |
| ---------------- | ------------------------------------ |
| Promise\<object> | Promise used to return the URI of the data item.|
**Example**
```js
settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS).then((uri) => {
console.log(`promise:uri -> ${JSON.stringify(uri)}`)
})
```
## setting.getValue<sup>(deprecated)</sup>
getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback\<object>): void
Obtains the value of a data item in the database. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9.
**Model restriction**: This API can be used only in the FA model.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br> - Existing data items in the database<br>- Custom data items|
| callback | AsyncCallback\<object> | Yes | Callback used to return the value of the data item. |
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility';
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, (err, value) => {
if (err) {
console.error(`Failed to get the setting. ${err.message} `);
return;
}
console.log(`callback:value -> ${JSON.stringify(value)}`)
});
```
## setting.getValue<sup>(deprecated)</sup>
getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise\<object>
Obtains the value of a data item in the database. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9.
**Model restriction**: This API can be used only in the FA model.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br> - Existing data items in the database<br>- Custom data items|
**Return value**
| Type | Description |
| ---------------- | ----------------------------------- |
| Promise\<object> | Promise used to return the value of the data item.|
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility';
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value) => {
console.log(`promise:value -> ${JSON.stringify(value)}`)
});
```
## settings.getValueSync<sup>(deprecated)</sup>
getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string
Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously. Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9.
**Model restriction**: This API can be used only in the FA model.
**System capability**: SystemCapability.Applications.settings.Core **System capability**: SystemCapability.Applications.settings.Core
**Parameters** **Parameters**
...@@ -514,7 +545,7 @@ Obtains the value of a data item. Unlike **getValue**, this API returns the resu ...@@ -514,7 +545,7 @@ Obtains the value of a data item. Unlike **getValue**, this API returns the resu
| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | | dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items| | name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
| defValue | string | Yes | Default value, which is returned when the value of a data item is not found in the database. Set this parameter as needed. | | defValue | string | Yes | Default value, which is returned when the value of a data item is not found in the database. Set this parameter as needed.|
**Return value** **Return value**
...@@ -533,7 +564,7 @@ let helper = featureAbility.acquireDataAbilityHelper(uri); ...@@ -533,7 +564,7 @@ let helper = featureAbility.acquireDataAbilityHelper(uri);
let value = settings.getValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '10'); let value = settings.getValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
``` ```
## settings.setValueSync<sup>8+</sup> ## settings.setValueSync<sup>(deprecated)</sup>
setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean
...@@ -541,6 +572,12 @@ Sets the value for a data item. Unlike **setValue**, this API returns the result ...@@ -541,6 +572,12 @@ Sets the value for a data item. Unlike **setValue**, this API returns the result
If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database. If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9.
**Model restriction**: This API can be used only in the FA model.
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS (available only to system applications) **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS (available only to system applications)
**System capability**: SystemCapability.Applications.settings.Core **System capability**: SystemCapability.Applications.settings.Core
......
...@@ -21,8 +21,6 @@ fetch(Object): void ...@@ -21,8 +21,6 @@ fetch(Object): void
Obtains data through a network. Obtains data through a network.
**Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetStack **System capability**: SystemCapability.Communication.NetStack
**Parameters** **Parameters**
...@@ -33,8 +31,8 @@ Obtains data through a network. ...@@ -33,8 +31,8 @@ Obtains data through a network.
| header | Object | No| Request header.| | header | Object | No| Request header.|
| method | string | No| Request method. The default value is **GET**. The value can be **OPTIONS**, **GET**, **HEAD**, **POST**, **PUT**, **DELETE **or **TRACE**.| | method | string | No| Request method. The default value is **GET**. The value can be **OPTIONS**, **GET**, **HEAD**, **POST**, **PUT**, **DELETE **or **TRACE**.|
| responseType | string | No| Response type. The return type can be text or JSON. By default, the return type is determined based on **Content-Type** in the header returned by the server. For details, see return values in the **success** callback.| | responseType | string | No| Response type. The return type can be text or JSON. By default, the return type is determined based on **Content-Type** in the header returned by the server. For details, see return values in the **success** callback.|
| success | Function | No| Called when the data is obtained successfully.| | success | Function | No| Called when data is obtained successfully. The return value is [FetchResponse](#fetchresponse). |
| fail | Function | No| Called when the data failed to be obtained.| | fail | Function | No| Called when data failed to be obtained.|
| complete | Function | No| Called when the execution is complete.| | complete | Function | No| Called when the execution is complete.|
**Table 1** Mapping between data and Content-Type **Table 1** Mapping between data and Content-Type
...@@ -46,7 +44,7 @@ Obtains data through a network. ...@@ -46,7 +44,7 @@ Obtains data through a network.
| Object | Not set| The default value of **Content-Type** is **application/x-www-form-urlencoded**. The **data** value is encoded based on the URL rule and appended in the request body.| | Object | Not set| The default value of **Content-Type** is **application/x-www-form-urlencoded**. The **data** value is encoded based on the URL rule and appended in the request body.|
| Object | application/x-www-form-urlencoded | The value of data is encoded based on the URL rule and is used as the request body.| | Object | application/x-www-form-urlencoded | The value of data is encoded based on the URL rule and is used as the request body.|
Return values in the **success** callback ## FetchResponse
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
......
...@@ -33,22 +33,15 @@ Obtains the network type. ...@@ -33,22 +33,15 @@ Obtains the network type.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| success | Function | No | Called&nbsp;when&nbsp;the&nbsp;execution&nbsp;is&nbsp;successful. | | success | Function | No | Called when the execution is successful. The return value is [NetworkResponse](#networkresponse). |
| fail | Function | No | Called&nbsp;when&nbsp;the&nbsp;operation&nbsp;fails. | | fail | Function | No | Called when the operation fails. |
| complete | Function | No | Called&nbsp;when&nbsp;the&nbsp;execution&nbsp;is&nbsp;complete | | complete | Function | No | Called when the execution is complete |
The following value will be returned when the multimedia volume is obtained. Return value of the **fail** callback:
| Parameter | Type | Description | | Error Code | Description |
| -------- | -------- | -------- |
| metered | boolean | Whether&nbsp;the&nbsp;billing&nbsp;is&nbsp;based&nbsp;on&nbsp;the&nbsp;data&nbsp;volume. |
| type | string | Network&nbsp;type.&nbsp;The&nbsp;value&nbsp;can&nbsp;be&nbsp;**2G**,&nbsp;**3G**,&nbsp;**4G**,&nbsp;**5G**,&nbsp;**WiFi**,&nbsp;or&nbsp;**none**. |
One of the following error codes will be returned if the operation fails.
| Error&nbsp;Code | Description |
| -------- | -------- | | -------- | -------- |
| 602 | The&nbsp;current&nbsp;permission&nbsp;is&nbsp;not&nbsp;declared. | | 602 | The current permission is not declared. |
**Example** **Example**
...@@ -80,22 +73,15 @@ Listens to the network connection state. If this method is called multiple times ...@@ -80,22 +73,15 @@ Listens to the network connection state. If this method is called multiple times
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| success | Function | No | Called&nbsp;when&nbsp;the&nbsp;network&nbsp;connection&nbsp;state&nbsp;changes | | success | Function | No | Called when the network connection state changes |
| fail | Function | No | Called&nbsp;when&nbsp;the&nbsp;multimedia&nbsp;volume&nbsp;fails&nbsp;to&nbsp;be&nbsp;obtained. | | fail | Function | No | Called when the multimedia volume fails to be obtained. |
The following value will be returned when the multimedia volume is obtained. Return value of the **fail** callback:
| Parameter | Type | Description |
| -------- | -------- | -------- |
| metered | boolean | Whether&nbsp;the&nbsp;billing&nbsp;is&nbsp;based&nbsp;on&nbsp;the&nbsp;data&nbsp;volume. |
| type | string | Network&nbsp;type.&nbsp;The&nbsp;value&nbsp;can&nbsp;be&nbsp;**2G**,&nbsp;**3G**,&nbsp;**4G**,&nbsp;**5G**,&nbsp;**WiFi**,&nbsp;or&nbsp;**none**. |
One of the following error codes will be returned if the listening fails. | Error Code | Description |
| Error&nbsp;Code | Description |
| -------- | -------- | | -------- | -------- |
| 602 | The&nbsp;current&nbsp;permission&nbsp;is&nbsp;not&nbsp;declared. | | 602 | The current permission is not declared. |
| 200 | The&nbsp;subscription&nbsp;fails. | | 200 | The subscription fails. |
**Example** **Example**
...@@ -131,4 +117,11 @@ export default { ...@@ -131,4 +117,11 @@ export default {
network.unsubscribe(); network.unsubscribe();
}, },
} }
``` ```
\ No newline at end of file
## NetworkResponse
| Parameter | Type | Description |
| -------- | -------- | -------- |
| metered | boolean | Whether the billing is based on the data volume. |
| type | string | Network type. The value can be **2G**, **3G**, **4G**, **5G**, **WiFi**, or **none**. |
\ No newline at end of file
...@@ -51,7 +51,7 @@ export default { ...@@ -51,7 +51,7 @@ export default {
## storage.set ## storage.set
get(options: SetStorageOptions): void set(options: SetStorageOptions): void
Sets the value in the cache based on the specified key. Sets the value in the cache based on the specified key.
...@@ -167,8 +167,8 @@ export default { ...@@ -167,8 +167,8 @@ export default {
| key | string | Yes | Key of the data to set. | | key | string | Yes | Key of the data to set. |
| value | string | Yes | New value to set. The length must be less than 128 bytes. | | value | string | Yes | New value to set. The length must be less than 128 bytes. |
| success | () => void | No | Called when **storage.set()** is called successfully. | | success | () => void | No | Called when **storage.set()** is called successfully. |
| fail | (data: string, code: number) => void | No | Called to return the result when **storage.get()** fails to be called. **data** is the error information, and **code** indicates the error code. | | fail | (data: string, code: number) => void | No | Called to return the result when **storage.set()** fails to be called. **data** is the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when **storage.get()** is complete. | | complete | () => void | No | Called when **storage.set()** is complete. |
## ClearStorageOptions ## ClearStorageOptions
......
...@@ -83,10 +83,10 @@ async function example() { ...@@ -83,10 +83,10 @@ async function example() {
console.info('fetchResult success'); console.info('fetchResult success');
let fileAsset = await fetchResult.getFirstObject(); let fileAsset = await fetchResult.getFirstObject();
if (fileAsset != undefined) { if (fileAsset != undefined) {
console.info("fileAsset.displayName :" + fileAsset.displayName); console.info("fileAsset.displayName : " + fileAsset.displayName);
} }
} else { } else {
console.info('fetchResult fail' + err); console.error('fetchResult fail' + err);
} }
}); });
} }
...@@ -137,7 +137,7 @@ async function example() { ...@@ -137,7 +137,7 @@ async function example() {
} }
} }
} catch (err) { } catch (err) {
console.info('getPhotoAssets failed, message = ', err); console.error('getPhotoAssets failed, message = ', err);
} }
} }
``` ```
...@@ -178,7 +178,7 @@ async function example() { ...@@ -178,7 +178,7 @@ async function example() {
console.info('createPhotoAsset file displayName' + fileAsset.displayName); console.info('createPhotoAsset file displayName' + fileAsset.displayName);
console.info('createPhotoAsset successfully'); console.info('createPhotoAsset successfully');
} else { } else {
console.info('createPhotoAsset failed, message = ', err); console.error('createPhotoAsset failed, message = ', err);
} }
}); });
} }
...@@ -212,7 +212,7 @@ async function example() { ...@@ -212,7 +212,7 @@ async function example() {
console.info('createPhotoAsset file displayName' + fileAsset.displayName); console.info('createPhotoAsset file displayName' + fileAsset.displayName);
console.info('createPhotoAsset successfully'); console.info('createPhotoAsset successfully');
} else { } else {
console.info('createPhotoAsset failed, message = ', err); console.error('createPhotoAsset failed, message = ', err);
} }
}); });
} }
...@@ -252,7 +252,7 @@ async function example() { ...@@ -252,7 +252,7 @@ async function example() {
console.info('createPhotoAsset file displayName' + fileAsset.displayName); console.info('createPhotoAsset file displayName' + fileAsset.displayName);
console.info('createPhotoAsset successfully'); console.info('createPhotoAsset successfully');
} catch (err) { } catch (err) {
console.info('createPhotoAsset failed, message = ', err); console.error('createPhotoAsset failed, message = ', err);
} }
} }
``` ```
...@@ -294,11 +294,11 @@ async function example() { ...@@ -294,11 +294,11 @@ async function example() {
if (album != undefined) { if (album != undefined) {
console.info('first album.albumName = ' + album.albumName); console.info('first album.albumName = ' + album.albumName);
} else { } else {
console.info('album is undefined, err = ', err); console.error('album is undefined, err = ', err);
} }
}); });
} else { } else {
console.info('getPhotoAlbums fail, message = ', err); console.error('getPhotoAlbums fail, message = ', err);
} }
}); });
} }
...@@ -343,7 +343,7 @@ async function example() { ...@@ -343,7 +343,7 @@ async function example() {
const album = await fetchResult.getFirstObject(); const album = await fetchResult.getFirstObject();
console.info('first album.albumName = ' + album.albumName); console.info('first album.albumName = ' + album.albumName);
} catch (err) { } catch (err) {
console.info('getPhotoAlbums fail, message = ' + err); console.error('getPhotoAlbums fail, message = ' + err);
} }
} }
``` ```
...@@ -376,7 +376,7 @@ async function example() { ...@@ -376,7 +376,7 @@ async function example() {
let trashAlbum = await fetchResult.getFirstObject(); let trashAlbum = await fetchResult.getFirstObject();
console.info('first album.albumName = ' + trashAlbum.albumName); console.info('first album.albumName = ' + trashAlbum.albumName);
} else { } else {
console.info('getPrivateAlbum failed. message = ', err); console.error('getPrivateAlbum failed. message = ', err);
} }
}); });
} }
...@@ -415,7 +415,7 @@ async function example() { ...@@ -415,7 +415,7 @@ async function example() {
let trashAlbum = await fetchResult.getFirstObject(); let trashAlbum = await fetchResult.getFirstObject();
console.info('first album.albumName = ' + trashAlbum.albumName); console.info('first album.albumName = ' + trashAlbum.albumName);
} catch (err) { } catch (err) {
console.info('getPrivateAlbum failed. message = ', err); console.error('getPrivateAlbum failed. message = ', err);
} }
} }
``` ```
...@@ -459,7 +459,7 @@ async function example() { ...@@ -459,7 +459,7 @@ async function example() {
console.info("fileAsset.displayName :" + fileAsset.displayName); console.info("fileAsset.displayName :" + fileAsset.displayName);
} }
} else { } else {
console.info('fetchFileResult fail' + err); console.error('fetchFileResult fail' + err);
} }
}); });
} }
...@@ -503,7 +503,7 @@ async function example() { ...@@ -503,7 +503,7 @@ async function example() {
try { try {
var fetchResult = await mgr.getAudioAssets(fetchOptions); var fetchResult = await mgr.getAudioAssets(fetchOptions);
} catch (err) { } catch (err) {
console.info('getAudioAssets failed, message = ', err); console.error('getAudioAssets failed, message = ', err);
} }
if (fetchResult != undefined) { if (fetchResult != undefined) {
...@@ -559,7 +559,7 @@ async function example() { ...@@ -559,7 +559,7 @@ async function example() {
if (err == undefined) { if (err == undefined) {
console.info("delete successfully"); console.info("delete successfully");
} else { } else {
console.info("delete failed with error:" + err); console.error("delete failed with error: " + err);
} }
}); });
} }
...@@ -613,7 +613,7 @@ async function example() { ...@@ -613,7 +613,7 @@ async function example() {
await mgr.delete(asset.uri); await mgr.delete(asset.uri);
console.info("delete successfully"); console.info("delete successfully");
} catch (err) { } catch (err) {
console.info("delete failed with error:" + err); console.error("delete failed with error: " + err);
} }
} }
``` ```
...@@ -649,13 +649,13 @@ async function example() { ...@@ -649,13 +649,13 @@ async function example() {
console.info('createPhotoAsset file displayName' + fileAsset.displayName); console.info('createPhotoAsset file displayName' + fileAsset.displayName);
console.info('createPhotoAsset successfully'); console.info('createPhotoAsset successfully');
} catch (err) { } catch (err) {
console.info('createPhotoAsset failed, message = ' + err); console.error('createPhotoAsset failed, message = ' + err);
} }
//sleep 1s //sleep 1s
if (count > 0) { if (count > 0) {
console.info("onDemo success"); console.info("onDemo success");
} else { } else {
console.info("onDemo fail"); console.error("onDemo fail");
} }
mgr.off('imageChange', () => { mgr.off('imageChange', () => {
// Unsubscription succeeds. // Unsubscription succeeds.
...@@ -699,13 +699,13 @@ async function example() { ...@@ -699,13 +699,13 @@ async function example() {
console.info('createPhotoAsset file displayName' + fileAsset.displayName); console.info('createPhotoAsset file displayName' + fileAsset.displayName);
console.info('createPhotoAsset successfully'); console.info('createPhotoAsset successfully');
} catch (err) { } catch (err) {
console.info('createPhotoAsset failed, message = ' + err); console.error('createPhotoAsset failed, message = ' + err);
} }
//sleep 1s //sleep 1s
if (count == 0) { if (count == 0) {
console.info("offDemo success"); console.info("offDemo success");
} else { } else {
console.info("offDemo fail"); console.error("offDemo fail");
} }
} }
``` ```
...@@ -736,7 +736,7 @@ async function example() { ...@@ -736,7 +736,7 @@ async function example() {
console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId); console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
} }
} else { } else {
console.info('getActivePeers failed. message = ', err); console.error('getActivePeers failed. message = ', err);
} }
}); });
} }
...@@ -764,7 +764,7 @@ async function example() { ...@@ -764,7 +764,7 @@ async function example() {
try { try {
var devicesInfo = await mgr.getActivePeers(); var devicesInfo = await mgr.getActivePeers();
} catch (err) { } catch (err) {
console.info('getActivePeers failed. message = ', err); console.error('getActivePeers failed. message = ', err);
} }
if (devicesInfo != undefined) { if (devicesInfo != undefined) {
console.log('getActivePeers succeed.'); console.log('getActivePeers succeed.');
...@@ -772,7 +772,7 @@ async function example() { ...@@ -772,7 +772,7 @@ async function example() {
console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId); console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
} }
} else { } else {
console.info('get distributed fail'); console.error('get distributed fail');
} }
} }
``` ```
...@@ -803,7 +803,7 @@ async function example() { ...@@ -803,7 +803,7 @@ async function example() {
console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId); console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
} }
} else { } else {
console.info('getAllPeers failed. message = ', err); console.error('getAllPeers failed. message = ', err);
} }
}); });
} }
...@@ -831,7 +831,7 @@ async function example() { ...@@ -831,7 +831,7 @@ async function example() {
try { try {
var devicesInfo = await mgr.getAllPeers(); var devicesInfo = await mgr.getAllPeers();
} catch (err) { } catch (err) {
console.info('getAllPeers failed. message = ', err); console.error('getAllPeers failed. message = ', err);
} }
if (devicesInfo != undefined) { if (devicesInfo != undefined) {
console.log('getAllPeers succeed.'); console.log('getAllPeers succeed.');
...@@ -839,7 +839,7 @@ async function example() { ...@@ -839,7 +839,7 @@ async function example() {
console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId); console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
} }
} else { } else {
console.info('get distributed fail'); console.error('get distributed fail');
} }
} }
``` ```
...@@ -866,7 +866,7 @@ async function example() { ...@@ -866,7 +866,7 @@ async function example() {
console.info('releaseDemo'); console.info('releaseDemo');
mgr.release((err) => { mgr.release((err) => {
if (err != undefined) { if (err != undefined) {
console.info('release failed. message = ', err); console.error('release failed. message = ', err);
} else { } else {
console.info('release ok.'); console.info('release ok.');
} }
...@@ -898,7 +898,7 @@ async function example() { ...@@ -898,7 +898,7 @@ async function example() {
await mgr.release(); await mgr.release();
console.info('release ok.'); console.info('release ok.');
} catch (err) { } catch (err) {
console.info('release failed. message = ', err); console.error('release failed. message = ', err);
} }
} }
``` ```
...@@ -951,7 +951,7 @@ async function example() { ...@@ -951,7 +951,7 @@ async function example() {
let fileAssetTitle = fileAsset.get(title.toString()); let fileAssetTitle = fileAsset.get(title.toString());
console.info('fileAsset Get fileAssetTitle = ', fileAssetTitle); console.info('fileAsset Get fileAssetTitle = ', fileAssetTitle);
} catch (err) { } catch (err) {
console.info('release failed. message = ', err); console.error('release failed. message = ', err);
} }
} }
``` ```
...@@ -989,7 +989,7 @@ async function example() { ...@@ -989,7 +989,7 @@ async function example() {
let title = userFileManager.ImageVideoKey.TITLE; let title = userFileManager.ImageVideoKey.TITLE;
fileAsset.set(title.toString(), "newTitle"); fileAsset.set(title.toString(), "newTitle");
} catch (err) { } catch (err) {
console.info('release failed. message = ', err); console.error('release failed. message = ', err);
} }
} }
``` ```
...@@ -1033,7 +1033,7 @@ async function example() { ...@@ -1033,7 +1033,7 @@ async function example() {
let newFileAssetTitle = fileAsset.get(title.toString()); let newFileAssetTitle = fileAsset.get(title.toString());
console.info('fileAsset Get newFileAssetTitle = ', newFileAssetTitle); console.info('fileAsset Get newFileAssetTitle = ', newFileAssetTitle);
} else { } else {
console.info('commitModify failed, message =', err); console.error('commitModify failed, message =', err);
} }
}); });
} }
...@@ -1078,7 +1078,7 @@ async function example() { ...@@ -1078,7 +1078,7 @@ async function example() {
let newFileAssetTitle = fileAsset.get(title.toString()); let newFileAssetTitle = fileAsset.get(title.toString());
console.info('fileAsset Get newFileAssetTitle = ', newFileAssetTitle); console.info('fileAsset Get newFileAssetTitle = ', newFileAssetTitle);
} catch (err) { } catch (err) {
console.info('release failed. message = ', err); console.error('release failed. message = ', err);
} }
} }
``` ```
...@@ -1089,9 +1089,7 @@ open(mode: string, callback: AsyncCallback&lt;number&gt;): void ...@@ -1089,9 +1089,7 @@ open(mode: string, callback: AsyncCallback&lt;number&gt;): void
Opens this file asset. This API uses an asynchronous callback to return the result. Opens this file asset. This API uses an asynchronous callback to return the result.
>**NOTE** **NOTE**<br>The write operations are mutually exclusive. After a write operation is complete, you must call **close** to release the resource.
>
>The write operations are mutually exclusive. After a write operation is complete, you must call **close** to release the resource.
**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.READ_AUDIO, ohos.permission.WRITE_IMAGEVIDEO, or ohos.permission.WRITE_AUDIO **Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.READ_AUDIO, ohos.permission.WRITE_IMAGEVIDEO, or ohos.permission.WRITE_AUDIO
...@@ -1103,7 +1101,7 @@ Opens this file asset. This API uses an asynchronous callback to return the resu ...@@ -1103,7 +1101,7 @@ Opens this file asset. This API uses an asynchronous callback to return the resu
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ----------------------------------- | | -------- | --------------------------- | ---- | ----------------------------------- |
| mode | string | Yes | File open mode, which can be **r** (read-only), **w** (write-only), or **rw** (read-write).| | mode | string | Yes | File open mode, which can be **r** (read-only), **w** (write-only), or **rw** (read-write).|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the file handle. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the file descriptor. |
**Example** **Example**
...@@ -1117,7 +1115,7 @@ async function example() { ...@@ -1117,7 +1115,7 @@ async function example() {
console.info('File fd' + fd); console.info('File fd' + fd);
fileAsset.close(fd); fileAsset.close(fd);
} else { } else {
console.info('File err' + err); console.error('File err' + err);
} }
}); });
} }
...@@ -1129,9 +1127,7 @@ open(mode: string): Promise&lt;number&gt; ...@@ -1129,9 +1127,7 @@ open(mode: string): Promise&lt;number&gt;
Opens this file asset. This API uses a promise to return the result. Opens this file asset. This API uses a promise to return the result.
>**NOTE** **NOTE**<br>The write operations are mutually exclusive. After a write operation is complete, you must call **close** to release the resource.
>
>The write operations are mutually exclusive. After a write operation is complete, you must call **close** to release the resource.
**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.READ_AUDIO, ohos.permission.WRITE_IMAGEVIDEO, or ohos.permission.WRITE_AUDIO **Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.READ_AUDIO, ohos.permission.WRITE_IMAGEVIDEO, or ohos.permission.WRITE_AUDIO
...@@ -1147,7 +1143,7 @@ Opens this file asset. This API uses a promise to return the result. ...@@ -1147,7 +1143,7 @@ Opens this file asset. This API uses a promise to return the result.
| Type | Description | | Type | Description |
| --------------------- | ------------- | | --------------------- | ------------- |
| Promise&lt;number&gt; | Promise used to return the file handle.| | Promise&lt;number&gt; | Promise used to return the file descriptor.|
**Example** **Example**
...@@ -1162,10 +1158,10 @@ async function example() { ...@@ -1162,10 +1158,10 @@ async function example() {
console.info('File fd' + fd); console.info('File fd' + fd);
fileAsset.close(fd); fileAsset.close(fd);
} else { } else {
console.info(' open File fail'); console.error(' open File fail');
} }
} catch (err) { } catch (err) {
console.info('open Demo err' + err); console.error('open Demo err' + err);
} }
} }
``` ```
...@@ -1206,11 +1202,11 @@ async function example() { ...@@ -1206,11 +1202,11 @@ async function example() {
if (err == undefined) { if (err == undefined) {
console.info('asset close succeed.'); console.info('asset close succeed.');
} else { } else {
console.info('close failed, message = ' + err); console.error('close failed, message = ' + err);
} }
}); });
} catch (err) { } catch (err) {
console.info('close failed, message = ' + err); console.error('close failed, message = ' + err);
} }
} }
``` ```
...@@ -1255,7 +1251,7 @@ async function example() { ...@@ -1255,7 +1251,7 @@ async function example() {
await asset.close(fd); await asset.close(fd);
console.info('asset close succeed.'); console.info('asset close succeed.');
} catch (err) { } catch (err) {
console.info('close failed, message = ' + err); console.error('close failed, message = ' + err);
} }
} }
``` ```
...@@ -1295,7 +1291,7 @@ async function example() { ...@@ -1295,7 +1291,7 @@ async function example() {
if (err == undefined) { if (err == undefined) {
console.info('getThumbnail successful ' + pixelMap); console.info('getThumbnail successful ' + pixelMap);
} else { } else {
console.info('getThumbnail fail', err); console.error('getThumbnail fail', err);
} }
}); });
} }
...@@ -1338,7 +1334,7 @@ async function example() { ...@@ -1338,7 +1334,7 @@ async function example() {
if (err == undefined) { if (err == undefined) {
console.info('getThumbnail successful ' + pixelMap); console.info('getThumbnail successful ' + pixelMap);
} else { } else {
console.info('getThumbnail fail', err); console.error('getThumbnail fail', err);
} }
}); });
} }
...@@ -1385,7 +1381,7 @@ async function example() { ...@@ -1385,7 +1381,7 @@ async function example() {
asset.getThumbnail(size).then((pixelMap) => { asset.getThumbnail(size).then((pixelMap) => {
console.info('getThumbnail successful ' + pixelMap); console.info('getThumbnail successful ' + pixelMap);
}).catch((err) => { }).catch((err) => {
console.info('getThumbnail fail' + err); console.error('getThumbnail fail' + err);
}); });
} }
``` ```
...@@ -1425,7 +1421,7 @@ async function example() { ...@@ -1425,7 +1421,7 @@ async function example() {
if (err == undefined) { if (err == undefined) {
console.info("favorite successfully"); console.info("favorite successfully");
} else { } else {
console.info("favorite failed with error:" + err); console.error("favorite failed with error:" + err);
} }
}); });
} }
...@@ -1470,7 +1466,7 @@ async function example() { ...@@ -1470,7 +1466,7 @@ async function example() {
asset.favorite(true).then(function () { asset.favorite(true).then(function () {
console.info("favorite successfully"); console.info("favorite successfully");
}).catch(function (err) { }).catch(function (err) {
console.info("favorite failed with error:" + err); console.error("favorite failed with error:" + err);
}); });
} }
``` ```
...@@ -1573,7 +1569,7 @@ async function example() { ...@@ -1573,7 +1569,7 @@ async function example() {
await fetchResult.close(); await fetchResult.close();
console.info('close succeed.'); console.info('close succeed.');
} catch (err) { } catch (err) {
console.info('close fail. message = ' + err); console.error('close fail. message = ' + err);
} }
} }
``` ```
...@@ -1609,7 +1605,7 @@ async function example() { ...@@ -1609,7 +1605,7 @@ async function example() {
if (fileAsset != undefined) { if (fileAsset != undefined) {
console.info('fileAsset displayName: ', fileAsset.displayName); console.info('fileAsset displayName: ', fileAsset.displayName);
} else { } else {
console.info("fileAsset failed with err:" + err); console.error("fileAsset failed with err:" + err);
} }
}); });
} }
...@@ -1680,7 +1676,7 @@ async function example() { ...@@ -1680,7 +1676,7 @@ async function example() {
if (fileAsset != undefined) { if (fileAsset != undefined) {
console.info('fileAsset displayName: ', fileAsset.displayName); console.info('fileAsset displayName: ', fileAsset.displayName);
} else { } else {
console.info("fileAsset failed with err:" + err); console.error("fileAsset failed with err: " + err);
} }
}); });
} }
...@@ -1753,7 +1749,7 @@ async function example() { ...@@ -1753,7 +1749,7 @@ async function example() {
if (fileAsset != undefined) { if (fileAsset != undefined) {
console.info('fileAsset displayName: ', fileAsset.displayName); console.info('fileAsset displayName: ', fileAsset.displayName);
} else { } else {
console.info("fileAsset failed with err:" + err); console.error("fileAsset failed with err: " + err);
} }
}); });
} }
...@@ -1823,7 +1819,7 @@ async function example() { ...@@ -1823,7 +1819,7 @@ async function example() {
if (fileAsset != undefined) { if (fileAsset != undefined) {
console.info('fileAsset displayName: ', fileAsset.displayName); console.info('fileAsset displayName: ', fileAsset.displayName);
} else { } else {
console.info("fileAsset failed with err:" + err); console.error("fileAsset failed with err: " + err);
} }
}); });
} }
...@@ -1920,9 +1916,9 @@ async function example() { ...@@ -1920,9 +1916,9 @@ async function example() {
const album = await albumList.getFirstObject(); const album = await albumList.getFirstObject();
album.getPhotoAssets(fetchOption, (err, albumFetchResult) => { album.getPhotoAssets(fetchOption, (err, albumFetchResult) => {
if (albumFetchResult != undefined) { if (albumFetchResult != undefined) {
console.info("album getPhotoAssets successfully, getCount:" + albumFetchResult.getCount()); console.info("album getPhotoAssets successfully, getCount: " + albumFetchResult.getCount());
} else { } else {
console.info("album getPhotoAssets failed with error:" + err); console.error("album getPhotoAssets failed with error: " + err);
} }
}); });
} }
...@@ -1963,9 +1959,9 @@ async function example() { ...@@ -1963,9 +1959,9 @@ async function example() {
const albumList = await mgr.getPhotoAlbums(albumFetchOptions); const albumList = await mgr.getPhotoAlbums(albumFetchOptions);
const album = await albumList.getFirstObject(); const album = await albumList.getFirstObject();
album.getPhotoAssets(fetchOption).then((albumFetchResult) => { album.getPhotoAssets(fetchOption).then((albumFetchResult) => {
console.info("album getFileAssets successfully, getCount:" + albumFetchResult.getCount()); console.info("album getFileAssets successfully, getCount: " + albumFetchResult.getCount());
}).catch((err) => { }).catch((err) => {
console.info("album getFileAssets failed with error:" + err); console.error("album getFileAssets failed with error: " + err);
}); });
} }
``` ```
...@@ -2002,7 +1998,7 @@ async function example() { ...@@ -2002,7 +1998,7 @@ async function example() {
album.albumName = 'hello'; album.albumName = 'hello';
album.commitModify((err) => { album.commitModify((err) => {
if (err != undefined) { if (err != undefined) {
console.info("commitModify failed with error:" + err); console.error("commitModify failed with error: " + err);
} else { } else {
console.info("commitModify successfully"); console.info("commitModify successfully");
} }
...@@ -2040,14 +2036,14 @@ async function example() { ...@@ -2040,14 +2036,14 @@ async function example() {
try { try {
var albumList = await mgr.getPhotoAlbums(albumFetchOptions); var albumList = await mgr.getPhotoAlbums(albumFetchOptions);
} catch (err) { } catch (err) {
console.info('getPhotoAlbums failed. message = ', err); console.error('getPhotoAlbums failed. message = ', err);
} }
const album = await albumList.getFirstObject(); const album = await albumList.getFirstObject();
album.albumName = 'hello'; album.albumName = 'hello';
album.commitModify().then(() => { album.commitModify().then(() => {
console.info("commitModify successfully"); console.info("commitModify successfully");
}).catch((err) => { }).catch((err) => {
console.info("commitModify failed with error:" + err); console.error("commitModify failed with error: " + err);
}); });
} }
``` ```
...@@ -2104,7 +2100,7 @@ async function example() { ...@@ -2104,7 +2100,7 @@ async function example() {
let count = fetchResult.getCount(); let count = fetchResult.getCount();
console.info('fetchResult.count = ', count); console.info('fetchResult.count = ', count);
} else { } else {
console.info('getFileAssets failed, message = ', err); console.error('getFileAssets failed, message = ', err);
} }
}); });
} }
...@@ -2187,7 +2183,7 @@ async function example() { ...@@ -2187,7 +2183,7 @@ async function example() {
let deleteFileUri = fileAsset.uri; let deleteFileUri = fileAsset.uri;
trashAlbum.delete(deleteFileUri, (err) => { trashAlbum.delete(deleteFileUri, (err) => {
if (err != undefined) { if (err != undefined) {
console.info('trashAlbum.delete failed, message = ', err); console.error('trashAlbum.delete failed, message = ', err);
} else { } else {
console.info('trashAlbum.delete successfully'); console.info('trashAlbum.delete successfully');
} }
...@@ -2236,7 +2232,7 @@ async function example() { ...@@ -2236,7 +2232,7 @@ async function example() {
trashAlbum.delete(deleteFileUri).then(() => { trashAlbum.delete(deleteFileUri).then(() => {
console.info('trashAlbum.delete successfully'); console.info('trashAlbum.delete successfully');
}).catch((err) => { }).catch((err) => {
console.info('trashAlbum.delete failed, message = ', err); console.error('trashAlbum.delete failed, message = ', err);
}); });
} }
``` ```
...@@ -2277,7 +2273,7 @@ async function example() { ...@@ -2277,7 +2273,7 @@ async function example() {
let recoverFileUri = fileAsset.uri; let recoverFileUri = fileAsset.uri;
trashAlbum.recover(recoverFileUri, (err) => { trashAlbum.recover(recoverFileUri, (err) => {
if (err != undefined) { if (err != undefined) {
console.info('trashAlbum.recover failed, message = ', err); console.error('trashAlbum.recover failed, message = ', err);
} else { } else {
console.info('trashAlbum.recover successfully'); console.info('trashAlbum.recover successfully');
} }
...@@ -2326,7 +2322,7 @@ async function example() { ...@@ -2326,7 +2322,7 @@ async function example() {
trashAlbum.recover(recoverFileUri).then(() => { trashAlbum.recover(recoverFileUri).then(() => {
console.info('trashAlbum.recover successfully'); console.info('trashAlbum.recover successfully');
}).catch((err) => { }).catch((err) => {
console.info('trashAlbum.recover failed, message = ', err); console.error('trashAlbum.recover failed, message = ', err);
}); });
} }
``` ```
...@@ -2339,9 +2335,9 @@ Enumerates the member types. ...@@ -2339,9 +2335,9 @@ Enumerates the member types.
| Name | Type| Readable | Writable | Description | | Name | Type| Readable | Writable | Description |
| ----- | ---- | ---- | ---- | ---- | | ----- | ---- | ---- | ---- | ---- |
| number | number | Yes| Yes| The member is a number.| | number | number | Yes| Yes| The member is a number.|
| string | string | Yes| Yes| The member is a string.| | string | string | Yes| Yes| The member is a string.|
| boolean | boolean | Yes| Yes| The member is a Boolean value.| | boolean | boolean | Yes| Yes| The member is a Boolean value.|
## ChangeEvent ## ChangeEvent
...@@ -2407,7 +2403,7 @@ Defines the key information about an audio file. ...@@ -2407,7 +2403,7 @@ Defines the key information about an audio file.
| URI | uri | File URI. | | URI | uri | File URI. |
| DISPLAY_NAME | display_name | File name displayed. | | DISPLAY_NAME | display_name | File name displayed. |
| DATE_ADDED | date_added | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. | | DATE_ADDED | date_added | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. |
| DATE_MODIFIED | date_modified | Date when the file was last modified. The value is the number of seconds elapsed since the Epoch time. | | DATE_MODIFIED | date_modified | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.|
| TITLE | title | Title in the file. | | TITLE | title | Title in the file. |
| ARTIST | artist | Author of the file. | | ARTIST | artist | Author of the file. |
| AUDIOALBUM | audio_album | Audio album. | | AUDIOALBUM | audio_album | Audio album. |
...@@ -2426,7 +2422,7 @@ Defines the key information about an image or video file. ...@@ -2426,7 +2422,7 @@ Defines the key information about an image or video file.
| FILE_TYPE | file_type | Type of the file. | | FILE_TYPE | file_type | Type of the file. |
| DISPLAY_NAME | display_name | File name displayed. | | DISPLAY_NAME | display_name | File name displayed. |
| DATE_ADDED | date_added | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. | | DATE_ADDED | date_added | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. |
| DATE_MODIFIED | date_modified | Date when the file was last modified. The value is the number of seconds elapsed since the Epoch time. | | DATE_MODIFIED | date_modified | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.|
| TITLE | title | Title in the file. | | TITLE | title | Title in the file. |
| DURATION | duration | Duration, in ms. | | DURATION | duration | Duration, in ms. |
| WIDTH | width | Image width, in pixels. | | WIDTH | width | Image width, in pixels. |
...@@ -2447,7 +2443,7 @@ Defines the key album information. ...@@ -2447,7 +2443,7 @@ Defines the key album information.
| FILE_TYPE | file_type | Type of the file. | | FILE_TYPE | file_type | Type of the file. |
| ALBUM_NAME | album_name | Name of the album. | | ALBUM_NAME | album_name | Name of the album. |
| DATE_ADDED | date_added | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. | | DATE_ADDED | date_added | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. |
| DATE_MODIFIED | date_modified | Date when the file was last modified. The value is the number of seconds elapsed since the Epoch time. | | DATE_MODIFIED | date_modified | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.|
## FetchOptions ## FetchOptions
......
...@@ -278,6 +278,8 @@ Sets whether to enable web debugging. ...@@ -278,6 +278,8 @@ Sets whether to enable web debugging.
| ------------------ | ------- | ---- | ------------- | | ------------------ | ------- | ---- | ------------- |
| webDebuggingAccess | boolean | Yes | Whether to enable web debugging.| | webDebuggingAccess | boolean | Yes | Whether to enable web debugging.|
**Example**
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview'; import web_webview from '@ohos.web.webview';
...@@ -305,7 +307,7 @@ struct WebComponent { ...@@ -305,7 +307,7 @@ struct WebComponent {
### loadUrl ### loadUrl
loadUrl(url: string | Resource, headers?: Array\<HeaderV9>): void loadUrl(url: string | Resource, headers?: Array\<WebHeader>): void
Loads a specified URL. Loads a specified URL.
...@@ -316,7 +318,7 @@ Loads a specified URL. ...@@ -316,7 +318,7 @@ Loads a specified URL.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ---------------- | ---- | :-------------------- | | ------- | ---------------- | ---- | :-------------------- |
| url | string \| Resource | Yes | URL to load. | | url | string \| Resource | Yes | URL to load. |
| headers | Array\<[HeaderV9](#headerv9)> | No | Additional HTTP request header of the URL.| | headers | Array\<[WebHeader](#webheader)> | No | Additional HTTP request header of the URL.|
**Error codes** **Error codes**
...@@ -344,6 +346,7 @@ struct WebComponent { ...@@ -344,6 +346,7 @@ struct WebComponent {
Button('loadUrl') Button('loadUrl')
.onClick(() => { .onClick(() => {
try { try {
// The URL to be loaded is of the string type.
this.controller.loadUrl('www.example.com'); this.controller.loadUrl('www.example.com');
} catch (error) { } catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
...@@ -355,6 +358,69 @@ struct WebComponent { ...@@ -355,6 +358,69 @@ struct WebComponent {
} }
``` ```
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('loadUrl')
.onClick(() => {
try {
// The headers parameter is carried.
this.controller.loadUrl('www.example.com', [{headerKey: "headerKey", headerValue: "headerValue"}]);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
.webDebuggingAccess(true)
}
}
}
```
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('loadUrl')
.onClick(() => {
try {
// The URL to be loaded is of the Resource type.
this.controller.loadUrl($rawfile('xxx.html'));
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
```html
<!-- xxx.html -->
<!DOCTYPE html>
<html>
<body>
<p>Hello World</p>
</body>
</html>
```
### loadData ### loadData
loadData(data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string): void loadData(data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string): void
...@@ -829,7 +895,7 @@ struct WebComponent { ...@@ -829,7 +895,7 @@ struct WebComponent {
### getHitTest ### getHitTest
getHitTest(): HitTestTypeV9 getHitTest(): WebHitTestType
Obtains the element type of the area being clicked. Obtains the element type of the area being clicked.
...@@ -839,7 +905,7 @@ Obtains the element type of the area being clicked. ...@@ -839,7 +905,7 @@ Obtains the element type of the area being clicked.
| Type | Description | | Type | Description |
| ------------------------------------------------------------ | ---------------------- | | ------------------------------------------------------------ | ---------------------- |
| [HitTestTypeV9](#hittesttypev9)| Element type of the area being clicked.| | [WebHitTestType](#webhittesttype)| Element type of the area being clicked.|
**Error codes** **Error codes**
...@@ -1026,7 +1092,7 @@ Executes a JavaScript script. This API uses a promise to return the script execu ...@@ -1026,7 +1092,7 @@ Executes a JavaScript script. This API uses a promise to return the script execu
| Type | Description | | Type | Description |
| --------------- | --------------------------------------------------- | | --------------- | --------------------------------------------------- |
| Promise\<string> | Callback used to return the result. Returns **null** if the JavaScript script fails to be executed| | Promise\<string> | Promise used to return the result. Returns **null** if the JavaScript script fails to be executed|
**Error codes** **Error codes**
...@@ -1512,7 +1578,7 @@ struct WebComponent { ...@@ -1512,7 +1578,7 @@ struct WebComponent {
this.ports = this.controller.createWebMessagePorts(); this.ports = this.controller.createWebMessagePorts();
// 2. Register a callback on a message port (for example, port 1) on the application side. // 2. Register a callback on a message port (for example, port 1) on the application side.
this.ports[1].onMessageEvent((result: web_webview.WebMessage) => { this.ports[1].onMessageEvent((result: web_webview.WebMessage) => {
var msg = 'Got msg from HTML:'; let msg = 'Got msg from HTML:';
if (typeof(result) == "string") { if (typeof(result) == "string") {
console.log("received string message from html5, string is:" + result); console.log("received string message from html5, string is:" + result);
msg = msg + result; msg = msg + result;
...@@ -1540,7 +1606,7 @@ struct WebComponent { ...@@ -1540,7 +1606,7 @@ struct WebComponent {
.onClick(() => { .onClick(() => {
try { try {
if (this.ports && this.ports[1]) { if (this.ports && this.ports[1]) {
this.ports[1].postMessageEvent("post message from ets to HTML"); this.ports[1].postMessageEvent("this.sendFromEts");
} else { } else {
console.error(`ports is null, Please initialize first`); console.error(`ports is null, Please initialize first`);
} }
...@@ -3579,7 +3645,7 @@ Deletes all data in the specified origin. ...@@ -3579,7 +3645,7 @@ Deletes all data in the specified origin.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------ | | ------ | ------ | ---- | ------------------------ |
| origin | string | Yes | Index of the origin.| | origin | string | Yes | Index of the origin, which is obtained through [getOrigins](#getorigins).|
**Error codes** **Error codes**
...@@ -4140,7 +4206,7 @@ Checks whether any saved HTTP authentication credentials exist. This API returns ...@@ -4140,7 +4206,7 @@ Checks whether any saved HTTP authentication credentials exist. This API returns
| Type | Description | | Type | Description |
| ------- | ------------------------------------------------------------ | | ------- | ------------------------------------------------------------ |
| boolean | Whether any saved HTTP authentication credentials exist. Returns **true** if any saved HTTP authentication credentials exist exists; returns **false** otherwise.| | boolean | Whether any saved HTTP authentication credentials exist. Returns **true** if any saved HTTP authentication credentials exist; returns **false** otherwise. |
**Example** **Example**
...@@ -4204,133 +4270,6 @@ struct WebComponent { ...@@ -4204,133 +4270,6 @@ struct WebComponent {
} }
``` ```
## WebAsyncController
Implements a **WebAsyncController** object, which can be used to control the behavior of a **\<Web>** component with asynchronous callbacks. A **WebAsyncController **object controls one **\<Web>** component.
### Creating an Object
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController();
webAsyncController: web_webview.WebAsyncController = new web_webview.WebAsyncController(this.controller)
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### constructor<sup>9+</sup>
constructor(controller: WebController)
Implements a **WebAsyncController** by binding it with a [WebController](../arkui-ts/ts-basic-components-web.md#webcontroller) object.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name| Type| Mandatory| Description|
| ----- | ---- | ---- | --- |
| controller | [WebController](../arkui-ts/ts-basic-components-web.md#webcontroller) | Yes| **WebviewController** to bind.|
### storeWebArchive<sup>9+</sup>
storeWebArchive(baseName: string, autoName: boolean, callback: AsyncCallback\<string>): void
Stores this web page. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------------------------------- |
| baseName | string | Yes| Save path. The value cannot be null. |
| autoName | boolean | Yes| Whether to automatically generate a file name.<br>The value **false** means not to automatically generate a file name.<br>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. |
| callback | AsyncCallback\<string> | Yes | Callback used to return the save path if the operation is successful and null otherwise.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('saveWebArchive')
.onClick(() => {
let webAsyncController = new web_webview.WebAsyncController(this.controller)
webAsyncController.storeWebArchive("/data/storage/el2/base/", true, (filename) => {
if (filename != null) {
console.info(`save web archive success: ${filename}`)
}
})
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### storeWebArchive<sup>9+</sup>
storeWebArchive(baseName: string, autoName: boolean): Promise\<string>
Stores this web page. This API uses a promise to return the result.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------------------------------- |
| baseName | string | Yes| Save path. The value cannot be null. |
| autoName | boolean | Yes| Whether to automatically generate a file name.<br>The value **false** means not to automatically generate a file name.<br>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. |
**Return value**
| Type | Description |
| ---------------- | ------------------------------------------------------------ |
| Promise\<string> | Promise used to return the save path if the operation is successful and null otherwise. |
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController();
build() {
Column() {
Button('saveWebArchive')
.onClick(() => {
let webAsyncController = new web_webview.WebAsyncController(this.controller);
webAsyncController.storeWebArchive("/data/storage/el2/base/", true)
.then(filename => {
if (filename != null) {
console.info(`save web archive success: ${filename}`)
}
})
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
## GeolocationPermissions ## GeolocationPermissions
Implements a **GeolocationPermissions** object. Implements a **GeolocationPermissions** object.
...@@ -4686,7 +4625,7 @@ struct WebComponent { ...@@ -4686,7 +4625,7 @@ struct WebComponent {
} }
} }
``` ```
## HeaderV9 ## WebHeader
Describes the request/response header returned by the **\<Web>** component. Describes the request/response header returned by the **\<Web>** component.
**System capability**: SystemCapability.Web.Webview.Core **System capability**: SystemCapability.Web.Webview.Core
...@@ -4696,7 +4635,7 @@ Describes the request/response header returned by the **\<Web>** component. ...@@ -4696,7 +4635,7 @@ Describes the request/response header returned by the **\<Web>** component.
| headerKey | string | Yes| Yes| Key of the request/response header. | | headerKey | string | Yes| Yes| Key of the request/response header. |
| headerValue | string | Yes| Yes| Value of the request/response header.| | headerValue | string | Yes| Yes| Value of the request/response header.|
## HitTestTypeV9 ## WebHitTestType
**System capability**: SystemCapability.Web.Webview.Core **System capability**: SystemCapability.Web.Webview.Core
...@@ -4719,7 +4658,7 @@ Provides the element information of the area being clicked. For details about th ...@@ -4719,7 +4658,7 @@ Provides the element information of the area being clicked. For details about th
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| ---- | ---- | ---- | ---- |---- | | ---- | ---- | ---- | ---- |---- |
| type | [HitTestTypeV9](#hittesttypev9) | Yes| No| Element type of the area being clicked.| | type | [WebHitTestType](#webhittesttype) | Yes| No| Element type of the area being clicked.|
| extra | string | Yes| No|Extra information of the area being clicked. If the area being clicked is an image or a link, the extra information is the URL of the image or link.| | extra | string | Yes| No|Extra information of the area being clicked. If the area being clicked is an image or a link, the extra information is the URL of the image or link.|
## WebMessage ## WebMessage
...@@ -4788,7 +4727,7 @@ import image from "@ohos.multimedia.image" ...@@ -4788,7 +4727,7 @@ import image from "@ohos.multimedia.image"
struct WebComponent { struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController(); controller: web_webview.WebviewController = new web_webview.WebviewController();
@State icon: image.PixelMap = undefined; @State icon: image.PixelMap = undefined;
build() { build() {
Column() { Column() {
Button('getBackForwardEntries') Button('getBackForwardEntries')
...@@ -4796,8 +4735,8 @@ struct WebComponent { ...@@ -4796,8 +4735,8 @@ struct WebComponent {
try { try {
let list = this.controller.getBackForwardEntries(); let list = this.controller.getBackForwardEntries();
let historyItem = list.getItemAtIndex(list.currentIndex); let historyItem = list.getItemAtIndex(list.currentIndex);
console.log("HistoryItem: " + JSON.stringify(historyItem)); console.log("HistoryItem: " + JSON.stringify(historyItem));
this.icon = historyItem.icon; this.icon = historyItem.icon;
} catch (error) { } catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
} }
......
...@@ -51,7 +51,7 @@ This component can contain only one child component. ...@@ -51,7 +51,7 @@ This component can contain only one child component.
| Normal | Normal button (without rounded corners by default). | | Normal | Normal button (without rounded corners by default). |
> **NOTE** > **NOTE**
> - The rounded corner of a button is set by using [borderRadius](ts-universal-attributes-border.md), rather than by using the **border** API. > - The rounded corner of a button is set by using [borderRadius](ts-universal-attributes-border.md), rather than by using the **border** API. Only a button-wide rounded corner setting is supported.
> - For a button of the **Capsule** type, the **borderRadius** settings do not take effect, and its rounded corner is always half of the button height. > - For a button of the **Capsule** type, the **borderRadius** settings do not take effect, and its rounded corner is always half of the button height.
> - For a button of the **Circle** type, its radius is the value of **borderRadius** (if set) or the width or height (whichever is smaller). > - For a button of the **Circle** type, its radius is the value of **borderRadius** (if set) or the width or height (whichever is smaller).
> - The button text is set using the [text style attributes](ts-universal-attributes-text-style.md). > - The button text is set using the [text style attributes](ts-universal-attributes-text-style.md).
......
...@@ -21,6 +21,7 @@ Web(options: { src: ResourceStr, controller: WebController | WebviewController}) ...@@ -21,6 +21,7 @@ Web(options: { src: ResourceStr, controller: WebController | WebviewController})
> **NOTE** > **NOTE**
> >
> Transition animation is not supported. > Transition animation is not supported.
> Different **\<Web>** components on the same page must be bound to different **WebController**s.
**Parameters** **Parameters**
...@@ -526,7 +527,7 @@ Sets whether to enable the multi-window permission. ...@@ -526,7 +527,7 @@ Sets whether to enable the multi-window permission.
horizontalScrollBarAccess(horizontalScrollBar: boolean) horizontalScrollBarAccess(horizontalScrollBar: boolean)
Sets whether to display the horizontal scrollbar, including the system default scrollbar and custom scrollbar. By default, the horizontal scrollbar is displayed. Sets whether to display the horizontal scrollbar, including the default system scrollbar and custom scrollbar. By default, the horizontal scrollbar is displayed.
**Parameters** **Parameters**
...@@ -1555,7 +1556,7 @@ onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisp ...@@ -1555,7 +1556,7 @@ onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisp
onErrorReceive(callback: (event?: { request: WebResourceRequest, error: WebResourceError }) => void) onErrorReceive(callback: (event?: { request: WebResourceRequest, error: WebResourceError }) => void)
Called when an error occurs during web page loading. For better results, simplify the implementation logic in the callback. Called when an error occurs during web page loading. For better results, simplify the implementation logic in the callback. This API is called when there is no network connection.
**Parameters** **Parameters**
...@@ -1780,7 +1781,7 @@ Called when the document title of the web page is changed. ...@@ -1780,7 +1781,7 @@ Called when the document title of the web page is changed.
onRefreshAccessedHistory(callback: (event?: { url: string, isRefreshed: boolean }) => void) onRefreshAccessedHistory(callback: (event?: { url: string, isRefreshed: boolean }) => void)
Called when loading of the web page is complete. This API is used by an application to update the historical link it accessed.. Called when loading of the web page is complete. This API is used by an application to update the historical link it accessed.
**Parameters** **Parameters**
...@@ -1966,7 +1967,7 @@ Called when the display ratio of this page changes. ...@@ -1966,7 +1967,7 @@ Called when the display ratio of this page changes.
onUrlLoadIntercept(callback: (event?: { data:string | WebResourceRequest }) => boolean) onUrlLoadIntercept(callback: (event?: { data:string | WebResourceRequest }) => boolean)
Called when the **\<Web>** component is about to access a URL. This API is used to determine whether to block the access. Called when the **\<Web>** component is about to access a URL. This API is used to determine whether to block the access, which is allowed by default.
**Parameters** **Parameters**
...@@ -2342,8 +2343,8 @@ Called when the scrollbar of the page scrolls. ...@@ -2342,8 +2343,8 @@ Called when the scrollbar of the page scrolls.
| Name | Type | Description | | Name | Type | Description |
| ------- | ------ | ------------ | | ------- | ------ | ------------ |
| xOffset | number | Position of the scrollbar on the x-axis.| | xOffset | number | Position of the scrollbar on the x-axis relative to the leftmost of the web page.|
| yOffset | number | Position of the scrollbar on the y-axis.| | yOffset | number | Position of the scrollbar on the y-axis relative to the top of the web page.|
**Example** **Example**
...@@ -2684,7 +2685,7 @@ Called when the old page is not displayed and the new page is about to be visibl ...@@ -2684,7 +2685,7 @@ Called when the old page is not displayed and the new page is about to be visibl
onInterceptKeyEvent(callback: (event: KeyEvent) => boolean) onInterceptKeyEvent(callback: (event: KeyEvent) => boolean)
Called when the key event is intercepted, before being consumed by the Webview. Called when the key event is intercepted and before it is consumed by the Webview.
**Parameters** **Parameters**
...@@ -2711,7 +2712,7 @@ Called when the key event is intercepted, before being consumed by the Webview. ...@@ -2711,7 +2712,7 @@ Called when the key event is intercepted, before being consumed by the Webview.
Column() { Column() {
Web({ src:'www.example.com', controller: this.controller }) Web({ src:'www.example.com', controller: this.controller })
.onInterceptKeyEvent((event) => { .onInterceptKeyEvent((event) => {
if (event.keyCode == 2017 || event.keyCode == 2018) { if (event.keyCode == 2017 || event.keyCode == 2018) {
console.info(`onInterceptKeyEvent get event.keyCode ${event.keyCode}`) console.info(`onInterceptKeyEvent get event.keyCode ${event.keyCode}`)
return true; return true;
} }
...@@ -3178,18 +3179,6 @@ Instructs the **\<Web>** component to select a file. ...@@ -3178,18 +3179,6 @@ Instructs the **\<Web>** component to select a file.
Implements the **FileSelectorParam** object. For the sample code, see [onShowFileSelector](#onshowfileselector9). Implements the **FileSelectorParam** object. For the sample code, see [onShowFileSelector](#onshowfileselector9).
### getTitle<sup>9+</sup>
getTitle(): string
Obtains the title of the file selector.
**Return value**
| Type | Description |
| ------ | ---------- |
| string | Title of the file selector.|
### getMode<sup>9+</sup> ### getMode<sup>9+</sup>
getMode(): FileSelectorMode getMode(): FileSelectorMode
...@@ -3813,40 +3802,6 @@ This API is deprecated since API version 9. You are advised to use [forward<sup> ...@@ -3813,40 +3802,6 @@ This API is deprecated since API version 9. You are advised to use [forward<sup>
} }
``` ```
### backOrForward<sup>9+</sup>
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.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ----------- |
| step | number | Yes | - | Number of the steps to take.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
@State step: number = -2
build() {
Column() {
Button('backOrForward')
.onClick(() => {
this.controller.backOrForward(this.step)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### deleteJavaScriptRegister<sup>(deprecated)</sup> ### deleteJavaScriptRegister<sup>(deprecated)</sup>
deleteJavaScriptRegister(name: string) deleteJavaScriptRegister(name: string)
...@@ -3919,73 +3874,6 @@ This API is deprecated since API version 9. You are advised to use [getHitTest<s ...@@ -3919,73 +3874,6 @@ This API is deprecated since API version 9. You are advised to use [getHitTest<s
} }
``` ```
### getHitTestValue<sup>9+</sup>
getHitTestValue(): HitTestValue
Obtains the element information of the area being clicked.
**Return value**
| Type | Description |
| ------------------------------ | ---------- |
| [HitTestValue](#hittestvalue9) | Element information of the area being clicked.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('getHitTestValue')
.onClick(() => {
let hitValue = this.controller.getHitTestValue()
console.log("hitType: " + hitValue.getType())
console.log("extra: " + hitValue.getExtra())
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### getWebId<sup>9+</sup>
getWebId(): number
Obtains the index value of this **\<Web>** component, which can be used for **\<Web>** component management.
**Return value**
| Type | Description |
| ------ | ------------ |
| number | Index value of the current **\<Web>** component.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('getWebId')
.onClick(() => {
let id = this.controller.getWebId()
console.log("id: " + id)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### getTitle<sup>9+</sup> ### getTitle<sup>9+</sup>
getTitle(): string getTitle(): string
...@@ -4019,72 +3907,6 @@ Obtains the title of the current web page. ...@@ -4019,72 +3907,6 @@ Obtains the title of the current web page.
} }
``` ```
### getPageHeight<sup>9+</sup>
getPageHeight(): number
Obtains the height of the current web page.
**Return value**
| Type | Description |
| ------ | ---------- |
| number | Height of the current web page.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('getPageHeight')
.onClick(() => {
let pageHeight = this.controller.getPageHeight()
console.log("pageHeight: " + pageHeight)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### getDefaultUserAgent<sup>9+</sup>
getDefaultUserAgent(): string
Obtains the default user agent of the current web page.
**Return value**
| Type | Description |
| ------ | ------- |
| string | Default user agent.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('getDefaultUserAgent')
.onClick(() => {
let userAgent = this.controller.getDefaultUserAgent()
console.log("userAgent: " + userAgent)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### loadData<sup>(deprecated)</sup> ### loadData<sup>(deprecated)</sup>
loadData(options: { data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string }) loadData(options: { data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string })
...@@ -4265,72 +4087,6 @@ This API is deprecated since API version 9. You are advised to use [zoom<sup>9+< ...@@ -4265,72 +4087,6 @@ This API is deprecated since API version 9. You are advised to use [zoom<sup>9+<
} }
``` ```
### zoomIn<sup>9+</sup>
zoomIn(): boolean
Zooms in on this web page by 20%.
**Return value**
| Type | Description |
| ------- | ----------- |
| boolean | Operation result.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('zoomIn')
.onClick(() => {
let result = this.controller.zoomIn()
console.log("result: " + result)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### zoomOut<sup>9+</sup>
zoomOut(): boolean
Zooms out of this web page by 20%.
**Return value**
| Type | Description |
| ------- | ----------- |
| boolean | Operation result.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('zoomOut')
.onClick(() => {
let result = this.controller.zoomOut()
console.log("result: " + result)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### refresh<sup>(deprecated)</sup> ### refresh<sup>(deprecated)</sup>
refresh() refresh()
...@@ -4547,11 +4303,17 @@ This API is deprecated since API version 9. You are advised to use [clearHistory ...@@ -4547,11 +4303,17 @@ This API is deprecated since API version 9. You are advised to use [clearHistory
} }
``` ```
### clearSslCache ### getCookieManager<sup>9+</sup>
getCookieManager(): WebCookie
Obtains the cookie management object of the **\<Web>** component.
clearSslCache(): void **Return value**
Clears the user operation corresponding to the SSL certificate error event recorded by the **\<Web>** component. | Type | Description |
| --------- | ---------------------------------------- |
| WebCookie | Cookie management object. For details, see [WebCookie](#webcookie).|
**Example** **Example**
...@@ -4564,9 +4326,9 @@ Clears the user operation corresponding to the SSL certificate error event recor ...@@ -4564,9 +4326,9 @@ Clears the user operation corresponding to the SSL certificate error event recor
build() { build() {
Column() { Column() {
Button('clearSslCache') Button('getCookieManager')
.onClick(() => { .onClick(() => {
this.controller.clearSslCache() let cookieManager = this.controller.getCookieManager()
}) })
Web({ src: 'www.example.com', controller: this.controller }) Web({ src: 'www.example.com', controller: this.controller })
} }
...@@ -4574,44 +4336,27 @@ Clears the user operation corresponding to the SSL certificate error event recor ...@@ -4574,44 +4336,27 @@ Clears the user operation corresponding to the SSL certificate error event recor
} }
``` ```
### clearClientAuthenticationCache ## WebCookie
clearClientAuthenticationCache(): void
Clears the user operation corresponding to the client certificate request event recorded by the **\<Web>** component.
**Example**
```ts Manages behavior of cookies in **\<Web>** components. All **\<Web>** components in an application share a **WebCookie**. You can use the **getCookieManager** API in **controller** to obtain the **WebCookie** for subsequent cookie management.
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() { ### setCookie<sup>9+</sup>
Column() { setCookie(url: string, value: string): boolean
Button('clearClientAuthenticationCache')
.onClick(() => {
this.controller.clearClientAuthenticationCache()
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### getCookieManager<sup>9+</sup> Sets the cookie. This API returns the result synchronously. Returns **true** if the operation is successful; returns **false** otherwise.
getCookieManager(): WebCookie **Parameters**
Obtains the cookie management object of the **\<Web>** component. | Name | Type | Mandatory | Default Value | Description |
| ----- | ------ | ---- | ---- | ----------------- |
| url | string | Yes | - | URL of the cookie to set.|
| value | string | Yes | - | Value of the cookie to set. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------- | ---------------------------------------- | | ------- | ------------- |
| WebCookie | Cookie management object. For details, see [WebCookie](#webcookie).| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -4624,28 +4369,26 @@ Obtains the cookie management object of the **\<Web>** component. ...@@ -4624,28 +4369,26 @@ Obtains the cookie management object of the **\<Web>** component.
build() { build() {
Column() { Column() {
Button('getCookieManager') Button('setCookie')
.onClick(() => { .onClick(() => {
let cookieManager = this.controller.getCookieManager() let result = this.controller.getCookieManager().setCookie("www.example.com", "a=b")
console.log("result: " + result)
}) })
Web({ src: 'www.example.com', controller: this.controller }) Web({ src: 'www.example.com', controller: this.controller })
} }
} }
} }
``` ```
### saveCookieSync<sup>9+</sup>
saveCookieSync(): boolean
### createWebMessagePorts<sup>9+</sup> Saves the cookies in the memory to the drive. This API returns the result synchronously.
createWebMessagePorts(): Array\<WebMessagePort\>
Creates web message ports.
**Return value** **Return value**
| Type | Description |
| Type | Description | | ------- | -------------------- |
| ---------------------------------------- | ---------- | | boolean | Operation result.|
| Array\<[WebMessagePort](#webmessageport9)\> | List of web message ports.|
**Example** **Example**
...@@ -4655,13 +4398,13 @@ Creates web message ports. ...@@ -4655,13 +4398,13 @@ Creates web message ports.
@Component @Component
struct WebComponent { struct WebComponent {
controller: WebController = new WebController() controller: WebController = new WebController()
ports: WebMessagePort[] = null
build() { build() {
Column() { Column() {
Button('createWebMessagePorts') Button('saveCookieSync')
.onClick(() => { .onClick(() => {
this.ports = this.controller.createWebMessagePorts() let result = this.controller.getCookieManager().saveCookieSync()
console.log("createWebMessagePorts size:" + this.ports.length) console.log("result: " + result)
}) })
Web({ src: 'www.example.com', controller: this.controller }) Web({ src: 'www.example.com', controller: this.controller })
} }
...@@ -4669,737 +4412,7 @@ Creates web message ports. ...@@ -4669,737 +4412,7 @@ Creates web message ports.
} }
``` ```
### postMessage<sup>9+</sup> ## MessageLevel
postMessage(options: { message: WebMessageEvent, uri: string}): void
Sends a web message to an HTML5 window.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------- | ------------------------------------ | ---- | ---- | ----------------- |
| message | [WebMessageEvent](#webmessageevent9) | Yes | - | Message to send, including the data and message port.|
| uri | string | Yes | - | URI for receiving the message. |
**Example**
```ts
// index.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
ports: WebMessagePort[] = null
@State sendFromEts: string = 'Send this message from ets to HTML'
@State receivedFromHtml: string = 'Display received message send from HTML'
build() {
Column() {
// Display the received HTML content.
Text(this.receivedFromHtml)
// Send the content in the text box to an HTML window.
TextInput({placeholder: 'Send this message from ets to HTML'})
.onChange((value: string) => {
this.sendFromEts = value
})
// 1. Create two message ports.
Button('1.CreateWebMessagePorts')
.onClick(() => {
this.ports = this.controller.createWebMessagePorts()
console.log("createWebMessagePorts size:" + this.ports.length)
})
// 2. Send one of the message ports to the HTML side, which can then save and use the port.
Button('2.PostMessagePort')
.onClick(() => {
var sendPortArray = new Array(this.ports[1])
var msgEvent = new WebMessageEvent()
msgEvent.setData("__init_port__")
msgEvent.setPorts(sendPortArray)
this.controller.postMessage({message: msgEvent, uri: "*"})
})
// 3. Register a callback for the other message port on the application side.
Button('3.RegisterCallback')
.onClick(() => {
this.ports[0].onMessageEvent((result: string) => {
var msg = 'Got msg from HTML: ' + result
this.receivedFromHtml = msg
})
})
// 4. Use the port on the application side to send messages to the message port that has been sent to the HTML.
Button('4.SendDataToHtml5')
.onClick(() => {
var msg = new WebMessageEvent()
msg.setData(this.sendFromEts)
this.ports[0].postMessageEvent(msg)
})
Web({ src: $rawfile("index.html"), controller: this.controller })
.javaScriptAccess(true)
.fileAccess(true)
}
}
}
// index.html
<!DOCTYPE html>
<html>
<body>
<h1>Web Message Port Demo</h1>
<div style="font-size: 24pt;">
<input type="button" value="5.SendToEts" onclick="PostMsgToEts(msgFromJS.value);" /><br/>
<input id="msgFromJS" type="text" value="send this message from HTML to ets" style="font-size: 16pt;" /><br/>
</div>
<p class="output">display received message send from ets</p>
</body>
<script src="index.js"></script>
</html>
// index.js
var h5Port;
var output = document.querySelector('.output');
window.addEventListener('message', function(event) {
if (event.data == '__init_port__') {
if(event.ports[0] != null) {
h5Port = event.ports[0]; // 1. Save the port number sent from the eTS side.
h5Port.onmessage = function(event) {
// 2. Receive the message sent from the eTS side.
var msg = 'Got message from ets:' + event.data;
output.innerHTML = msg;
}
}
}
})
// 3. Use h5Port to send messages to the eTS side.
function PostMsgToEts(data) {
h5Port.postMessage(data)
}
```
### getUrl<sup>9+</sup>
getUrl(): string
Obtains the URL of this page.
**Return value**
| Type | Description |
| ------ | ----------- |
| string | URL of the current page.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('getUrl')
.onClick(() => {
console.log("url: " + this.controller.getUrl())
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### searchAllAsync<sup>9+</sup>
searchAllAsync(searchString: string): void
Searches the web page for content that matches the keyword specified by **'searchString'** and highlights the matches on the page. This API returns the result asynchronously through [onSearchResultReceive](#onsearchresultreceive9).
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------------ | ------ | ---- | ---- | ------- |
| searchString | string | Yes | - | Search keyword.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
@State searchString: string = "xxx"
build() {
Column() {
Button('searchString')
.onClick(() => {
this.controller.searchAllAsync(this.searchString)
})
Button('clearMatches')
.onClick(() => {
this.controller.clearMatches()
})
Button('searchNext')
.onClick(() => {
this.controller.searchNext(true)
})
Web({ src: 'www.example.com', controller: this.controller })
.onSearchResultReceive(ret => {
console.log("on search result receive:" + "[cur]" + ret.activeMatchOrdinal +
"[total]" + ret.numberOfMatches + "[isDone]"+ ret.isDoneCounting)
})
}
}
}
```
### clearMatches<sup>9+</sup>
clearMatches(): void
Clears the matches found through [searchAllAsync](#searchallasync9).
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('clearMatches')
.onClick(() => {
this.controller.clearMatches()
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### searchNext<sup>9+</sup>
searchNext(forward: boolean): void
Searches for and highlights the next match.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------- | ------- | ---- | ---- | ----------- |
| forward | boolean | Yes | - | Whether to search forward.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('searchNext')
.onClick(() => {
this.controller.searchNext(true)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
## HitTestValue<sup>9+</sup>
Implements the **HitTestValue** object. For the sample code, see [getHitTestValue](#gethittestvalue9).
### getType<sup>9+</sup>
getType(): HitTestType
Obtains the element type of the area being clicked.
**Return value**
| Type | Description |
| ------------------------------- | ------------- |
| [HitTestType](#hittesttype)| Element type of the area being clicked.|
### getExtra<sup>9+</sup>
getExtra(): string
Obtains the extra information of the area being clicked. If the area being clicked is an image or a link, the extra information is the URL of the image or link.
**Return value**
| Type | Description |
| ------ | ------------ |
| string | Extra information of the area being clicked.|
## WebCookie
Manages behavior of cookies in **\<Web>** components. All **\<Web>** components in an application share a **WebCookie**. You can use the **getCookieManager** API in **controller** to obtain the **WebCookie** for subsequent cookie management.
### setCookie<sup>9+</sup>
setCookie(url: string, value: string): boolean
Sets the cookie. This API returns the result synchronously. Returns **true** if the operation is successful; returns **false** otherwise.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ----- | ------ | ---- | ---- | ----------------- |
| url | string | Yes | - | URL of the cookie to set.|
| value | string | Yes | - | Value of the cookie to set. |
**Return value**
| Type | Description |
| ------- | ------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('setCookie')
.onClick(() => {
let result = this.controller.getCookieManager().setCookie("www.example.com", "a=b")
console.log("result: " + result)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### saveCookieSync<sup>9+</sup>
saveCookieSync(): boolean
Saves the cookies in the memory to the drive. This API returns the result synchronously.
**Return value**
| Type | Description |
| ------- | -------------------- |
| boolean | Operation result.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('saveCookieSync')
.onClick(() => {
let result = this.controller.getCookieManager().saveCookieSync()
console.log("result: " + result)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### getCookie<sup>9+</sup>
getCookie(url: string): string
Obtains the cookie value corresponding to the specified URL.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ----------------- |
| url | string | Yes | - | URL of the cookie value to obtain.|
**Return value**
| Type | Description |
| ------ | ----------------- |
| string | Cookie value corresponding to the specified URL.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('getCookie')
.onClick(() => {
let value = web_webview.WebCookieManager.getCookie('www.example.com')
console.log("value: " + value)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### setCookie<sup>9+</sup>
setCookie(url: string, value: string): boolean
Sets a cookie value for the specified URL.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ----- | ------ | ---- | ---- | ----------------- |
| url | string | Yes | - | URL of the cookie to set.|
| value | string | Yes | - | Cookie value to set. |
**Return value**
| Type | Description |
| ------- | ------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('setCookie')
.onClick(() => {
let result = web_webview.WebCookieManager.setCookie('www.example.com', 'a=b')
console.log("result: " + result)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### saveCookieAsync<sup>9+</sup>
saveCookieAsync(): Promise\<boolean>
Saves the cookies in the memory to the drive. This API uses a promise to return the value.
**Return value**
| Type | Description |
| ----------------- | --------------------------- |
| Promise\<boolean> | Promise used to return the result.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('saveCookieAsync')
.onClick(() => {
web_webview.WebCookieManager.saveCookieAsync()
.then (function(result) {
console.log("result: " + result)
})
.catch(function(error) {
console.error("error: " + error)
})
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### saveCookieAsync<sup>9+</sup>
saveCookieAsync(callback: AsyncCallback\<boolean>): void
Saves the cookies in the memory to the drive. This API uses an asynchronous callback to return the result.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| -------- | ----------------------- | ---- | ---- | ---------------------------- |
| callback | AsyncCallback\<boolean> | Yes | - | Callback used to return the operation result.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('saveCookieAsync')
.onClick(() => {
web_webview.WebCookieManager.saveCookieAsync(function(result) {
console.log("result: " + result)
})
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### isCookieAllowed<sup>9+</sup>
isCookieAllowed(): boolean
Checks whether the **WebCookieManager** instance has the permission to send and receive cookies.
**Return value**
| Type | Description |
| ------- | ------------------- |
| boolean | Whether the **WebCookieManager** instance has the permission to send and receive cookies.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('isCookieAllowed')
.onClick(() => {
let result = web_webview.WebCookieManager.isCookieAllowed()
console.log("result: " + result)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### putAcceptCookieEnabled<sup>9+</sup>
putAcceptCookieEnabled(accept: boolean): void
Sets whether the **WebCookieManager** instance has the permission to send and receive cookies.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------- | ---- | ---- | --------------------- |
| accept | boolean | Yes | - | Whether the **WebCookieManager** instance has the permission to send and receive cookies.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('putAcceptCookieEnabled')
.onClick(() => {
web_webview.WebCookieManager.putAcceptCookieEnabled(false)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### isThirdPartyCookieAllowed<sup>9+</sup>
isThirdCookieAllowed(): boolean
Checks whether the **WebCookieManager** instance has the permission to send and receive third-party cookies.
**Return value**
| Type | Description |
| ------- | ---------------------- |
| boolean | Whether the **WebCookieManager** instance has the permission to send and receive third-party cookies.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('isThirdPartyCookieAllowed')
.onClick(() => {
let result = web_webview.WebCookieManager.isThirdPartyCookieAllowed()
console.log("result: " + result)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### putAcceptThirdPartyCookieEnabled<sup>9+</sup>
putAcceptThirdPartyCookieEnabled(accept: boolean): void
Sets whether the **WebCookieManager** instance has the permission to send and receive third-party cookies.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------- | ---- | ---- | ------------------------ |
| accept | boolean | Yes | - | Whether the **WebCookieManager** instance has the permission to send and receive third-party cookies.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('putAcceptThirdPartyCookieEnabled')
.onClick(() => {
web_webview.WebCookieManager.putAcceptThirdPartyCookieEnabled(false)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### existCookie<sup>9+</sup>
existCookie(): boolean
Checks whether cookies exist.
**Return value**
| Type | Description |
| ------- | ----------- |
| boolean | Whether cookies exist.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('existCookie')
.onClick(() => {
let result = web_webview.WebCookieManager.existCookie()
console.log("result: " + result)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### deleteEntireCookie<sup>9+</sup>
deleteEntireCookie(): void
Deletes all cookies.
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('deleteEntireCookie')
.onClick(() => {
web_webview.WebCookieManager.deleteEntireCookie()
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### deleteSessionCookie<sup>9+</sup>
deleteSessionCookie(): void
Deletes all session cookies.
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('deleteSessionCookie')
.onClick(() => {
web_webview.WebCookieManager.deleteSessionCookie()
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
## MessageLevel
| Name | Description | | Name | Description |
| ----- | :---- | | ----- | :---- |
...@@ -5482,227 +4495,6 @@ Enumerates the error codes returned by **onSslErrorEventReceive** API. ...@@ -5482,227 +4495,6 @@ Enumerates the error codes returned by **onSslErrorEventReceive** API.
| On | The web dark mode is enabled. | | On | The web dark mode is enabled. |
| Auto | The web dark mode setting follows the system settings. | | Auto | The web dark mode setting follows the system settings. |
## WebMessagePort<sup>9+</sup>
Implements a **WebMessagePort** instance, which can be used to send and receive messages.
### close<sup>9+</sup>
close(): void
Disables this message port.
### postMessageEvent<sup>9+</sup>
postMessageEvent(message: WebMessageEvent): void
Sends messages. For the complete sample code, see [postMessage](#postmessage9).
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------- | ------------------------------------ | ---- | ---- | ------- |
| message | [WebMessageEvent](#webmessageevent9) | Yes | - | Message to send.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
ports: WebMessagePort[] = null
build() {
Column() {
Button('postMessageEvent')
.onClick(() => {
var msg = new WebMessageEvent()
msg.setData("post message from ets to html5")
this.ports[0].postMessageEvent(msg)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### onMessageEvent<sup>9+</sup>
onMessageEvent(callback: (result: string) => void): void
Registers a callback to receive messages from an HTML5 page. For the complete sample code, see [postMessage](#postmessage9).
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | ---- | ---- | ---------- |
| callback | function | Yes | - | Callback for receiving messages.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
ports: WebMessagePort[] = null
build() {
Column() {
Button('onMessageEvent')
.onClick(() => {
this.ports[0].onMessageEvent((result: string) => {
console.log("received message from html5, on message:" + result);
})
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
## WebMessageEvent<sup>9+</sup>
Implements the **WebMessageEvent** object to encapsulate the message and port.
### getData<sup>9+</sup>
getData(): string
Obtains the messages stored in this object.
**Return value**
| Type | Description |
| ------ | -------------- |
| string | Message stored in the object of this type.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
build() {
Column() {
Button('getPorts')
.onClick(() => {
var msgEvent = new WebMessageEvent();
msgEvent.setData("message event data")
var messageData = msgEvent.getData()
console.log("message is:" + messageData)
})
}
}
}
```
### setData<sup>9+</sup>
setData(data: string): void
Sets the message in this object. For the complete sample code, see [postMessage](#postmessage9).
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ------- |
| data | string | Yes | - | Message to send.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
ports: WebMessagePort[] = null
build() {
Column() {
Button('setData')
.onClick(() => {
var msg = new WebMessageEvent()
msg.setData("post message from ets to HTML5")
this.ports[0].postMessageEvent(msg)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### getPorts<sup>9+</sup>
getPorts(): Array\<WebMessagePort\>
Obtains the message port stored in this object.
**Return value**
| Type | Description |
| ---------------------------------------- | ---------------- |
| Array\<[WebMessagePort](#webmessageport9)\> | Message port stored in the object of this type.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
ports: WebMessagePort[] = null
build() {
Column() {
Button('getPorts')
.onClick(() => {
var sendPortArray = new Array(this.ports[0])
var msgEvent = new WebMessageEvent()
msgEvent.setPorts(sendPortArray)
var getPorts = msgEvent.getPorts()
console.log("Ports is:" + getPorts)
})
}
}
}
```
### setPorts<sup>9+</sup>
setPorts(ports: Array\<WebMessagePort\>): void
Sets the message port in this object. For the complete sample code, see [postMessage](#postmessage9).
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ----- | ---------------------------------------- | ---- | ---- | --------- |
| ports | Array\<[WebMessagePort](#webmessageport9)\> | Yes | - | Message port.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
ports: WebMessagePort[] = null
build() {
Column() {
Button('setPorts')
.onClick(() => {
var sendPortArray = new Array(this.ports[1])
var msgEvent = new WebMessageEvent()
msgEvent.setData("__init_ports__")
msgEvent.setPorts(sendPortArray)
this.controller.postMessage({message: msgEvent, uri: "*"})
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
## DataResubmissionHandler<sup>9+</sup> ## DataResubmissionHandler<sup>9+</sup>
Implements the **DataResubmissionHandler** object for resubmitting or canceling the web form data. Implements the **DataResubmissionHandler** object for resubmitting or canceling the web form data.
......
...@@ -37,7 +37,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -37,7 +37,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| viewPort | {<br>x?: number \| string,<br>y?: number \| string,<br>width?: number \| string,<br>height?: number \| string<br>} | { x:0, y:0, width:0, height:0 } | View port of the shape.| | viewPort | {<br>x?: number \| string,<br>y?: number \| string,<br>width?: number \| string,<br>height?: number \| string<br>} | { x:0, y:0, width:0, height:0 } | View port of the shape.|
| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.| | fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.|
| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.| | fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.|
| stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, no stroke is displayed.| | stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.|
| strokeDashArray | Array&lt;Length&gt; | [] | Stroke dashes.| | strokeDashArray | Array&lt;Length&gt; | [] | Stroke dashes.|
| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.| | strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.|
| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.|
...@@ -145,91 +145,3 @@ struct ShapeExample { ...@@ -145,91 +145,3 @@ struct ShapeExample {
``` ```
![en-us_image_0000001184628104](figures/en-us_image_0000001184628104.png) ![en-us_image_0000001184628104](figures/en-us_image_0000001184628104.png)
### Example 2
```ts
// xxx.ets
@Entry
@Component
struct ShapeMeshExample {
@State columnVal: number = 0
@State rowVal: number = 0
@State count: number = 0
@State verts: Array<number> = []
@State shapeWidth: number = 600
@State shapeHeight: number = 600
build() {
Column() {
Shape() {
Rect()
.width('250px')
.height('250px')
.radiusWidth('10px')
.radiusHeight('10px')
.stroke('10px')
.margin({ left: '10px', top: '10px' })
.strokeWidth('10px')
.fill(Color.Blue)
Rect()
.width('250px')
.height('250px')
.radiusWidth('10px')
.radiusHeight('10px')
.stroke('10px')
.margin({ left: '270px', top: '10px' })
.strokeWidth('10px')
.fill(Color.Red)
}
.mesh(this.verts, this.columnVal, this.rowVal)
.width(this.shapeWidth + 'px')
.height(this.shapeHeight + 'px')
// The mesh distortion effect is displayed when the component is touched.
.onTouch((event: TouchEvent) => {
var touchX = event.touches[0].x * 2
var touchY = event.touches[0].y * 2
this.columnVal = 20
this.rowVal = 20
this.count = (this.columnVal + 1) * (this.rowVal + 1)
var orig = [this.count * 2]
var index = 0
for (var i = 0; i <= this.rowVal; i++) {
var fy = this.shapeWidth * i / this.rowVal
for (var j = 0; j <= this.columnVal; j++) {
var fx = this.shapeWidth * j / this.columnVal
orig[index * 2 + 0] = this.verts[index * 2 + 0] = fx
orig[index * 2 + 1] = this.verts[index * 2 + 1] = fy
index++;
}
}
for (var k = 0; k < this.count * 2; k += 2) {
var dx = touchX - orig[k + 0]
var dy = touchY - orig[k + 1]
var dd = dx * dx + dy * dy
var d = Math.sqrt(dd)
var pull = 80000 / (dd * d)
if (pull >= 1) {
this.verts[k + 0] = touchX
this.verts[k + 1] = touchY
} else {
this.verts[k + 0] = orig[k + 0] + dx * pull
this.verts[k + 1] = orig[k + 1] + dy * pull
}
}
})
}
.width('600px')
.height('600px')
.border({ width: 3, color: Color.Black })
}
}
```
Below is how the component is displayed when not being touched.
![en-us_image1_0000001184628104](figures/en-us_image1_0000001184628104.png)
The mesh distortion effect is displayed when the component is touched, as shown below.
![en-us_image2_0000001184628104](figures/en-us_image2_0000001184628104.png)
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
The [Ability Privilege Level (APL)](accesstoken-overview.md#app-apls) of an application can be **normal**, **system_basic**, or **system_core**. The default APL is **normal**. The [permission types](accesstoken-overview.md#permission-types) include **system_grant** and **user_grant**. For details about the permissions for applications, see the [Application Permission List](permission-list.md). The [Ability Privilege Level (APL)](accesstoken-overview.md#app-apls) of an application can be **normal**, **system_basic**, or **system_core**. The default APL is **normal**. The [permission types](accesstoken-overview.md#permission-types) include **system_grant** and **user_grant**. For details about the permissions for applications, see the [Application Permission List](permission-list.md).
This document describes: This document describes the following operations:
- [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file) - [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file)
- [Declaring Permissions in the ACL](#declaring-permissions-in-the-acl) - [Declaring the ACL](#declaring-the-acl)
- [Requesting User Authorization](#requesting-user-authorization) - [Requesting User Authorization](#requesting-user-authorization)
- [Pre-Authorizing user_grant Permissions](#pre-authorizing-user_grant-permissions) - [Pre-Authorizing user_grant Permissions](#pre-authorizing-user_grant-permissions)
...@@ -15,22 +15,22 @@ This document describes: ...@@ -15,22 +15,22 @@ This document describes:
During the development, you need to declare the permissions required by your application one by one in the project configuration file. The application cannot obtain the permissions that are not declared in the configuration file. OpenHarmony provides two application models: FA model and stage model. For more information, see [Application Models](../application-models/application-model-description.md). The application bundle and configuration file vary with the application model. During the development, you need to declare the permissions required by your application one by one in the project configuration file. The application cannot obtain the permissions that are not declared in the configuration file. OpenHarmony provides two application models: FA model and stage model. For more information, see [Application Models](../application-models/application-model-description.md). The application bundle and configuration file vary with the application model.
> **NOTE**<br>The default APL of an application is **normal**. When an application needs the **system_basic** or **system_core** APL, you must declare the permission in the configuration file and the [Access Control List (ACL)](#declaring-permissions-in-the-acl). > **NOTE**<br>The default APL of an application is **normal**. When an application of the **normal** APL needs a permission of the **system_basic** or **system_core** level, you must declare the permission in the configuration file and the [Access Control List (ACL)](#declaring-the-acl).
The following table describes the fields in the configuration file. The following table describes the fields in the configuration file.
| Field | Mandatory| Description | | Field | Mandatory| Description |
| --------- | -------- | ------------------------------------------------------------ | | --------- | -------- | ------------------------------------------------------------ |
| name | Yes | Name of the permission. | | name | Yes | Name of the permission. |
| reason | No | Reason for requesting the permission.<br>This field is mandatory when the requested permission needs user authorization (user_grant).| | reason | No | Reason for requesting the permission.<br>This field is mandatory when a user_grant permission is required.|
| usedScene | No | Application scenario of the permission.<br>This field is mandatory when the requested permission needs user authorization (user_grant).| | usedScene | No | Application scenario of the permission.<br>This field is mandatory when a user_grant permission is required.|
| abilities | No | Abilities that require the permission. The value is an array.<br>**Applicable model**: stage| | abilities | No | Abilities that require the permission. The value is an array.<br>**Applicable model**: stage|
| ability | No | Abilities that require the permission. The value is an array.<br>**Applicable model**: FA| | ability | No | Abilities that require the permission. The value is an array.<br>**Applicable model**: FA|
| when | No | Time when the permission is used. <br>Value:<br>- **inuse**: The permission applies only to a foreground application.<br>- **always**: The permission applies to both the foreground and background applications.| | when | No | Time when the permission is used. <br>Value:<br>- **inuse**: The permission applies only to a foreground application.<br>- **always**: The permission applies to both the foreground and background applications.|
### Stage Model ### Stage Model
If the application is based on the stage model, declare the permissions in [**module.json5**](../quick-start/module-configuration-file.md). If your application is based on the stage model, declare the required permissions in [**module.json5**](../quick-start/module-configuration-file.md).
```json ```json
{ {
...@@ -64,7 +64,7 @@ If the application is based on the stage model, declare the permissions in [**mo ...@@ -64,7 +64,7 @@ If the application is based on the stage model, declare the permissions in [**mo
### FA Model ### FA Model
If the application is based on the FA model, declare the required permissions in **config.json**. If your application is based on the FA model, declare the required permissions in **config.json**.
```json ```json
{ {
...@@ -96,11 +96,11 @@ If the application is based on the FA model, declare the required permissions in ...@@ -96,11 +96,11 @@ If the application is based on the FA model, declare the required permissions in
} }
``` ```
## Declaring Permissions in the ACL ## Declaring the ACL
If an application of the **normal** level requires permissions corresponding to the **system_basic** or **system_core** level, you need to declare the required permissions in the ACL. If an application of the **normal** APL requires permissions of the **system_basic** or **system_core** level, you need to declare the required permissions in the ACL.
For example, if an application needs to access audio files of a user and capture screenshots, it requires the **ohos.permission.WRITE_AUDIO** permission (of the **system_basic** level) and the **ohos.permission.CAPTURE_SCREEN** permission (of the **system_core** level). In this case, you need to add the related permissions to the **acl** field in the [HarmonyAppProvision configuration file](app-provision-structure.md). For example, if an application needs to access audio files of a user and capture screenshots, it requires the **ohos.permission.WRITE_AUDIO** permission (of the **system_basic** level) and the **ohos.permission.CAPTURE_SCREEN** permission (of the **system_core** level). In this case, you need to add the required permissions to the **acls** field in the [HarmonyAppProvision configuration file](app-provision-structure.md).
```json ```json
{ {
...@@ -116,11 +116,11 @@ For example, if an application needs to access audio files of a user and capture ...@@ -116,11 +116,11 @@ For example, if an application needs to access audio files of a user and capture
## Requesting User Authorization ## Requesting User Authorization
If an application needs to access user privacy information or use system abilities, for example, accessing location or calendar information or using the camera to take photos or record videos, it must request the permission from users. A permission verification is performed first to determine whether the current invoker has the corresponding permission. If the application has not obtained that permission, a dialog box will be displayed to request user authorization. The following figure shows an example. If an application needs to access user privacy information or use system abilities, for example, accessing location or calendar information or using the camera to take photos or record videos, it must request the permission from the user. A permission verification is performed first to determine whether the current caller has the corresponding permission. If the application has not obtained that permission, a dialog box will be displayed to request user authorization. The following figure shows an example.
![](figures/permission-read_calendar.png) ![](figures/permission-read_calendar.png)
> **NOTE**<br>Each time before an API protected by a permission is accessed, [**requestPermissionsFromUser()**](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) will be called to request user authorization. After a permission is dynamically granted, the user may revoke the permission. Therefore, the previously granted authorization status cannot be persistent. > **NOTE**<br>Each time before an API protected by a user_grant permission is accessed, [**requestPermissionsFromUser()**](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) will be called to request user authorization. After the permission is dynamically granted, the user may revoke the authorization. Therefore, the previously granted authorization status cannot be persistent.
### Stage Model ### Stage Model
...@@ -128,7 +128,7 @@ Example: Request the permission for an application to access calendar informatio ...@@ -128,7 +128,7 @@ Example: Request the permission for an application to access calendar informatio
1. Apply for the **ohos.permission.READ_CALENDAR** permission. For details, see [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file). 1. Apply for the **ohos.permission.READ_CALENDAR** permission. For details, see [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file).
2. Call [**requestPermissionsFromUser()**](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) in the **onWindowStageCreate()** callback of the UIAbility to dynamically apply for the permission, or request user authorization on the UI based on service requirements. The return value of [requestPermissionsFromUser()](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) indicates whether the application has the target permission. If yes, the target API can be called normally. 2. Call [**requestPermissionsFromUser()**](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) in the **onWindowStageCreate()** callback of the UIAbility to dynamically apply for the permission, or request user authorization on the UI based on service requirements. The return value of [requestPermissionsFromUser()](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) indicates whether the application has the permission. If yes, the target API can be called.
Request user authorization in UIAbility. Request user authorization in UIAbility.
...@@ -149,11 +149,14 @@ Example: Request the permission for an application to access calendar informatio ...@@ -149,11 +149,14 @@ Example: Request the permission for an application to access calendar informatio
atManager.requestPermissionsFromUser(context, permissions).then((data) => { atManager.requestPermissionsFromUser(context, permissions).then((data) => {
console.info(`[requestPermissions] data: ${JSON.stringify(data)}`); console.info(`[requestPermissions] data: ${JSON.stringify(data)}`);
let grantStatus: Array<number> = data.authResults; let grantStatus: Array<number> = data.authResults;
if (grantStatus[0] === -1) { let length: number = grantStatus.length;
// The authorization fails. for (let i = 0; i < length; i++) {
} else { if (grantStatus[i] !== 0) {
// The authorization is successful. // The authorization fails.
return;
}
} }
// The authorization is successful.
}).catch((err) => { }).catch((err) => {
console.error(`[requestPermissions] Failed to start request permissions. Error: ${JSON.stringify(err)}`); console.error(`[requestPermissions] Failed to start request permissions. Error: ${JSON.stringify(err)}`);
}) })
...@@ -179,11 +182,14 @@ Example: Request the permission for an application to access calendar informatio ...@@ -179,11 +182,14 @@ Example: Request the permission for an application to access calendar informatio
atManager.requestPermissionsFromUser(context, permissions).then((data) => { atManager.requestPermissionsFromUser(context, permissions).then((data) => {
console.info(`[requestPermissions] data: ${JSON.stringify(data)}`); console.info(`[requestPermissions] data: ${JSON.stringify(data)}`);
let grantStatus: Array<number> = data.authResults; let grantStatus: Array<number> = data.authResults;
if (grantStatus[0] === -1) { let length: number = grantStatus.length;
// The authorization fails. for (let i = 0; i < length; i++) {
} else { if (grantStatus[i] !== 0) {
// The authorization is successful. // The authorization fails.
return;
}
} }
// The authorization is successful.
}).catch((err) => { }).catch((err) => {
console.error(`[requestPermissions] Failed to start request permissions. Error: ${JSON.stringify(err)}`); console.error(`[requestPermissions] Failed to start request permissions. Error: ${JSON.stringify(err)}`);
}) })
...@@ -217,7 +223,7 @@ reqPermissions() { ...@@ -217,7 +223,7 @@ reqPermissions() {
} }
``` ```
## Pre-Authorizing user_grant Permissions ## Pre-Authorizing user_grant Permissions
By default, the **user_grant** permissions must be dynamically authorized by the user through a dialog box. However, for pre-installed applications, you can pre-authorize the permissions, for example, the **ohos.permission.MICROPHONE** permission for camera applications, in the [**install_list_permission.json**] file to prevent the user authorization dialog box from being displayed. The [**install_list_permissions.json** file](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) is in the **/system/etc/app/** directory on a device. When the device is started, the **install_list_permissions.json** file is loaded. When the application is installed, the **user_grant** permissions in the file are granted. The **install_list_permissions.json** file contains the following fields: By default, the **user_grant** permissions must be dynamically authorized by the user through a dialog box. However, for pre-installed applications, you can pre-authorize the permissions, for example, the **ohos.permission.MICROPHONE** permission for camera applications, in the [**install_list_permission.json**](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) file to prevent the user authorization dialog box from being displayed. The **install_list_permissions.json** file is in the **/system/etc/app/** directory on a device. When the device is started, the **install_list_permissions.json** file is loaded. When the application is installed, the user_grant permissions in the file are granted. The **install_list_permissions.json** file contains the following fields:
- **bundleName**: bundle name of the application. - **bundleName**: bundle name of the application.
- **app_signature**: fingerprint information of the application. For details, see **Configuration in install_list_capability.json** in [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). - **app_signature**: fingerprint information of the application. For details, see **Configuration in install_list_capability.json** in [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md).
......
# Access Control (Permission) Overview # Access Control (Permission) Overview
OpenHarmony AccessTokenManager (ATM) implements unified app permission management based on access tokens. OpenHarmony AccessTokenManager (ATM) implements unified management of application permissions based on access tokens.
By default, apps can access limited system resources. However, to provide extended features, an app may need to access excess data (including personal data) and functions of the system or another app. The system or apps must also explicitly share their data or functions through APIs. OpenHarmony uses app permissions to perform access control and prevent improper or malicious use of these data or functions. By default, applications can access limited system resources. However, to provide extended features, an application may need to access excess data (including personal data) and functions of the system or another application. The system or applications must also explicitly share their data or functions through APIs. OpenHarmony uses application permissions to prevent unauthorized access to and improper or malicious use of these data or functions.
App permissions are used to protect the following objects: Application permissions are used to protect the following objects:
- Data: personal data (such as photos, contacts, calendar, and location), device data (such as device ID, camera, and microphone), and app data. - Data: includes personal data (such as photos, contacts, calendar, and location), device data (such as device ID, camera, and microphone), and application data.
- Functions: device functions (such as making calls, sending SMS messages, and connecting to the Internet) and app functions (such as displaying windows and creating shortcuts). - Functions: includes device functions (such as making calls, sending SMS messages, and connecting to the Internet) and application functions (such as displaying windows and creating shortcuts).
Without the required permissions, an app cannot access or perform operations on the target object. Permissions must be clearly defined for apps. With well-defined app permissions, the system can standardize app behavior and protect user privacy. Before an app accesses the target object, the target object verifies the app's permissions and denies the access if the app does not have required permissions. Without the required permissions, an application cannot access or perform operations on the target object. Permissions must be clearly defined for applications. With well-defined application permissions, the system can standardize application behavior and protect user privacy. Before an application accesses an object, the object verifies the application's permissions and denies the access if the application does not have required permissions.
Currently, ATM verifies app permissions based on the token identity (token ID). A token ID identifies an app. ATM manages app permissions based on the app's token ID. Currently, ATM verifies application permissions based on the token identity (token ID). A token ID identifies an application. ATM manages application permissions based on the application's token ID.
## Basic Principles for Permission Management ## Basic Principles for Permission Management
Observe the following principles for permission management: Observe the following permission management principles:
- Provide clear description about the functions and scenarios for each permission required by the app so that users can clearly know why and when these permissions are needed. Do not induce or mislead users' authorization. The permissions on an app must comply with the description provided in the app. - Provide clear description about the usage and scenario for each permission required by the application so that user can clearly know why and when these permissions are needed. Do not induce or mislead users' authorization. The permissions on an application must comply with the description provided in the application.
- Use the principle of least authority for user permissions. Allow only necessary permissions for service functions. - Use the principle of least authority for application permissions. Allow only necessary permissions for service functions.
- When an app is started for the first time, avoid frequently displaying dialog boxes to request multiple permissions. Allow the app to apply for the permission only when it needs to use the corresponding service function. - When an application is started for the first time, avoid frequently displaying dialog boxes to request multiple permissions. Allow the application to apply for the permission only when it needs to use the corresponding service function.
- If a user rejects to grant a permission, the user can still use functions irrelevant to this permission and can register and access the app. - If a user rejects to grant a permission, the user can still use functions irrelevant to this permission and can register and access the application.
- Provide no more message if a user rejects the authorization required by a function. Provide onscreen instructions to direct the user to grant the permission in **Settings** if the user triggers this function again or needs to use this function. - Provide no more message if a user rejects the authorization required by a function. Provide onscreen instructions to direct the user to grant the permission in **Settings** if the user triggers this function again or needs to use this function.
- All the permissions granted to apps must come from the [App Permission List](permission-list.md). Custom permissions are not allowed currently. - All the permissions for applications must come from the [Application Permission List](permission-list.md). Custom permissions are not allowed currently.
## Permission Workflows ## Permission Workflows
### Permission Application and Use ### Applying for and Using a Permission
Determine the permissions required by an app, and declare the required permissions in the app installation package. Determine the permissions required by an application, and declare the required permissions in the application installation package.
Determine whether the required permissions need user authorization. If yes, display a dialog box dynamically to request user authorization. Determine whether the required permissions need user authorization. If yes, display a dialog box dynamically to request user authorization.
After the user grants the permissions, the app can access the data or perform the operation. After the user grants the permissions, the application can access the data or perform the operation.
The figure below illustrates the process. The figure below illustrates the process.
![](figures/permission-workflow.png) ![](figures/permission-workflow.png)
1. Refer to the figure below to determine whether an app can apply for a permission. 1. Refer to the figure below to determine whether an application can apply for a permission.
![](figures/permission-application-process.png) ![](figures/permission-application-process.png)
1. See [Permission Levels](#permission-levels) for details about the mapping between the application Ability Privilege Level (APL) and permission level. 1. See [Permission Levels](#permission-levels) for details about the mapping between the application Ability Privilege Level (APL) and the permission level.
2. The permission authorization modes include user_grant (permission granted by the user) and system_grant (permission granted by the system). For details, see [Permission Types](#permission-types). 2. The permission authorization modes include user_grant (permission granted by the user) and system_grant (permission granted by the system). For details, see [Permission Types](#permission-types).
3. A low-APL app can have a high-level permission by using the Access Control List (ACL). For details, see [ACL](#acl). 3. A low-APL application can have a high-level permission by using the Access Control List (ACL). For details, see [ACL](#acl).
### Permission Verification ### Verifying a Permission
To protect sensitive data and eliminate security threads on core abilities, you can use the permissions in the [App Permission List](permission-list.md) to protect an API from unauthorized calling. Each time before the API is called, a permission verification is performed to check whether the caller has the required permission. To protect sensitive data and eliminate security threats on core abilities, you can use the permissions in the [Application Permission List](permission-list.md) to protect an API from unauthorized calling. Each time before the API is called, a verification is performed to check whether the caller has the required permission.
The API can be called only after the permission verification is successful. The API can be called only after the permission verification is successful.
...@@ -58,37 +58,37 @@ The figure below shows the permission verification process. ...@@ -58,37 +58,37 @@ The figure below shows the permission verification process.
![](figures/permission-verify-process.png) ![](figures/permission-verify-process.png)
1: An app permission can be used to control the access to an API that has sensitive data involved or security threats on the core abilities. 1: An application permission can be used to control the access to an API that has sensitive data involved or security threats on core abilities.
2: The API can be protected by a permission in the [ACL](#acl). For example, if contact information is involved in an API provided by an app, you can use the contact-related permissions to protect the API. 2: The API can be protected by a permission in the [ACL](#acl). For example, if contact information is involved in an API provided by an application, you can use a contact-related permission to protect the API.
3: Use **verifyAccessToken()** to check whether the caller has the required permission. For details, see [Permission Verification Guide](permission-verify-guidelines.md). 3: Use **checkAccessToken()** to check whether the caller has the required permission. For details, see [API Access Permission Verification](permission-verify-guidelines.md).
## Permission Levels ## Permission Levels
ATM defines different permission levels based on the sensitivity of the data involved or the security threat of the ability to protect user privacy. ATM defines different permission levels based on the sensitivity of the data involved or the security threat of the ability to protect user privacy.
### App APLs ### Application APLs
The APL defines the priority of the app permission requested. Apps of different APLs can apply for permissions of different levels. The APL defines the priority for an application to apply for permissions. Applications of different APLs can apply for permissions of different levels.
The table below describes the APLs. The following table describes the APLs.
| APL | Description | | APL | Description |
| ---------------- | -------------------------------------- | | ---------------- | -------------------------------------- |
| system_core | The apps of this level provide core abilities of the operating system (OS). | | system_core | Application that provides core abilities of the operating system (OS). |
| system_basic| The apps of this level provide basic system services. | | system_basic| Application that provides basic system services. |
| Normal | The apps of this level are normal apps. | | normal | Normal application. |
The default APL of apps is **normal**. The default APL of applications is **normal**.
To set an app's APL to **system_basic** or **system_core**, declare the APL in the **apl** field of **bundle-info** in the app's profile when developing the app's installation package. To set an application's APL to **system_basic** or **system_core**, set the **apl** field under **bundle-info** in the application's profile when developing the application's installation package.
Then, use the [hapsigner](hapsigntool-overview.md) tool to generate a certificate or use DevEco Studio to [have your app automatically signed](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465#section161281722111). Then, use the [hapsigner](hapsigntool-overview.md) tool to generate a certificate or use DevEco Studio to [have your application automatically signed](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465#section161281722111).
> **CAUTION**<br>The method of changing the app's APL in its profile applies only to the app or service in debug mode. For a commercial app, apply for a release certificate and profile in the corresponding app market. > **CAUTION**<br>The method of changing the application's APL in its profile applies only to the application or service in debug mode. For a commercial application, apply for a release certificate and profile in the corresponding application market.
The following is an example. Example:
This example shows only the modification of the **apl** field. Set other fields based on your requirements. For details about the fields in the profile, see [HarmonyAppProvision Configuration File](app-provision-structure.md). This example shows only the modification of the **apl** field. Set other fields based on your requirements. For details about the fields in the profile, see [HarmonyAppProvision Configuration File](app-provision-structure.md).
...@@ -107,25 +107,25 @@ This example shows only the modification of the **apl** field. Set other fields ...@@ -107,25 +107,25 @@ This example shows only the modification of the **apl** field. Set other fields
### Levels of Permissions ### Levels of Permissions
The permissions open to apps vary with the permission level. The permission levels include the following in ascending order of seniority. The permissions available to applications vary with the APL. The permission levels include the following in ascending order of seniority.
- **normal** - **normal**
The normal permission allows access to common system resources beyond the default rules. Access to these system resources (including data and functions) has minor risks on user privacy and other apps. The **normal** permission allows access to common system resources beyond the default rules. Access to these resources (including data and functions) has minor risks on user privacy and other applications.
The permissions of this level are available only to apps of the normal or higher APL. The permissions of this level are available to applications of the **normal** or higher APL.
- **system_basic** - **system_basic**
The system_basic permission allows access to resources related to basic OS services. The basic services are basic functions provided or preconfigured by the system, such as system settings and identity authentication. Access to these resources may have considerable risks to user privacy and other apps. The **system_basic** permission allows access to resources related to basic OS services. The basic services are basic functions provided or preconfigured by the system, such as system settings and identity authentication. Access to these resources may have considerable risks to user privacy and other applications.
The permissions of this level are available only to apps of the system_basic or system_core APL. The permissions of this level are available only to applications of the **system_basic** or **system_core** APL.
- **system_core** - **system_core**
The system_core permission allows access to core resources of the OS. These resources are underlying core services of the system. If these resources are corrupted, the OS cannot run properly. The **system_core** permission allows access to core resources of the OS. These resources are underlying core services of the system. If these resources are corrupted, the OS cannot run properly.
The system_core permissions are not open to third-party apps. The **system_core** permissions are not available to third-party applications.
## Permission Types ## Permission Types
...@@ -133,80 +133,80 @@ Permissions can be classified into the following types based on the authorizatio ...@@ -133,80 +133,80 @@ Permissions can be classified into the following types based on the authorizatio
- **system_grant** - **system_grant**
The app permissions are authorized by the system. Apps granted with this type of permission cannot access user or device sensitive information, and the operations allowed for them have minor impact on the system or other apps. A system_grant permission is authorized by the system. The application with this type of permission cannot access user or device sensitive information, and the operations allowed have minor impact on the system or other applications.
For a system_grant app, the system automatically grants the required permissions to the app when the app is installed. The system_grant permission list must be presented to users on the details page of the app in the app market. For an application with a system_grant permission, the system automatically grants the permission to the application when the application is installed. The system_grant permission list must be presented to users on the details page of the application in the application market.
- **user_grant** - **user_grant**
The app permissions must be authorized by users. Apps granted with this type of permissions may access user or device sensitive information, and the operations allowed for them may have a critical impact on the system or other apps. A user_grant permission must be authorized by the user. An application with this type of permission may access user or device sensitive information, and the operations allowed may have a critical impact on the system or other applications.
This type of permissions must be declared in the app installation package and authorized by users dynamically during the running of the app. The app has the permission only after user authorization. This type of permissions must be declared in the application installation package and authorized by users dynamically during the running of the application. The application has the permission only after user authorization.
For example, as described in the [App Permission List](permission-list.md), the permissions for microphones and cameras are user_grant. The list provides reasons for using the permissions. For example, the permissions for microphones and cameras in the [Application Permission List](permission-list.md) are user_grant. The list provides information about when to use the permissions.
The user_grant permission list must also be presented on the details page of the app in the app market. The user_grant permission list must also be presented on the details page of each application in the application market.
### Authorization Processes ### Authorization Processes
As described in [Permission Workflows](permission-workflows), you need to first apply for the required permissions for the app. As described in [Permission Workflows](permission-workflows), you need to first apply for the required permissions for your application.
- Applying for permissions - Applying for a permission
You need to [declare the required permissions](accesstoken-guidelines.md#declaring-permissions) in the configuration file. You need to [declare the required permissions](accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file) in the configuration file.
- Authorizing permissions - Authorizing a permission
- The system_grant permission will be pre-granted when the app is installed. - The system_grant permission is pre-granted when the application is installed.
- For a user_grant permission, you need to trigger user authorization through a dialog box during the running of the app. For details, see [Requesting User Authorization](#requesting-user-authorization). - For a user_grant permission, you need to trigger user authorization through a dialog box during the running of the application. For details, see [Requesting User Authorization](#requesting-user-authorization).
### Requesting User Authorization ### Requesting User Authorization
The procedure is as follows: The procedure is as follows:
1. In the configuration file, declare the permissions required by the app. For details, see [Access Control Development](accesstoken-guidelines.md). 1. In the configuration file, declare the permissions required by your application. For details, see [Permission Application Guide](accesstoken-guidelines.md).
2. Associate the target objects in the app with the related permissions. This allows the users to know the operations that need user authorization. 2. Associate the target object in the application with the required permission. This allows the users to know the operations that need user authorization.
3. Use an API to dynamically trigger a dialog box requesting user authorization when the target object is accessed. The API first checks whether the user has granted the required permissions to the app. If yes, the app can access the data or perform the operation. Otherwise, a dialog box will be displayed to request user authorization. 3. Use an API to dynamically trigger a dialog box for requesting user authorization when the target object is accessed. This API first checks whether the user has granted the permission required. If no, a dialog box will be displayed to request authorization from the user.
4. Check the user authorization result. Allow the subsequent operation only after the user has granted the permissions to the app. 4. Check the user authorization result. Allow the subsequent operations only after the user has granted the permission to the application successfully.
**Precautions** **Caution**
- Check the app's permission each time before the operation requiring the permission is performed. - Each time before the operation that requires the target permission is performed, the application must check whether the permission is available.
- To check whether a user has granted specific permissions to an app, use the [verifyAccessToken](../reference/apis/js-apis-abilityAccessCtrl.md) API. This API returns [PERMISSION_GRANTED](../reference/apis/js-apis-abilityAccessCtrl.md) or [PERMISSION_DENIED](../reference/apis/js-apis-abilityAccessCtrl.md). For details about the sample code, see [Access Control Development](accesstoken-guidelines.md). - To check whether a user has granted a permission to your application, use [checkAccessToken()](../reference/apis/js-apis-abilityAccessCtrl.md#checkaccesstoken9). This API returns [PERMISSION_GRANTED](../reference/apis/js-apis-abilityAccessCtrl.md) or [PERMISSION_DENIED](../reference/apis/js-apis-abilityAccessCtrl.md). For details about the sample code, see [Permission Application Guide](accesstoken-guidelines.md).
- Users must be able to understand and control the authorization of user_grant permissions. During the running process, the app requiring user authorization must proactively call an API to dynamically request the authorization. Then, the system displays a dialog box asking the user to grant the permission. The user will determine whether to grant the permission based on the running context of the app. - Users must be able to understand and control the authorization of user_grant permissions. For a user_grant permission, the application must proactively call an API to dynamically request user authorization. Then, the system displays a dialog box asking the user to grant the permission. The user then determines whether to grant the permission.
- The permission authorized is not permanent, because the user may revoke the authorization at any time. Therefore, even if the user has granted the requested permission to the app, the app must check for the permission before calling the API controlled by this permission. - The user may revoke the permission authorization at any time. Therefore, each time before an API associated with a user_grant permission is called, the application must check whether the permission is available.
## ACL ## ACL
As described above, permission levels and app APLs are in one-to-one correspondence. In principle, **an app with a lower APL cannot apply for higher permissions by default**. Permission levels and application APLs are in one-to-one correspondence. In principle, an application with a lower APL cannot apply for higher-level permissions by default.
The ACL makes low-APL apps have high-level permissions. The ACL makes low-APL applications have high-level permissions.
**Example** **Example:**
The APL of app A is **normal**. App A needs to have permission B (system_basic level) and permission C (normal level). The APL of application A is **normal**. Application A needs to have permission B (system_basic level) and permission C (normal level).
In this case, you can use the ACL to grant permission B to app A. In this case, you can use the ACL to grant permission B to application A.
For details, see [Using the ACL](#using-the-acl). For details, see [Using the ACL](#using-the-acl).
For details about whether a permission can be enabled through the ACL, see [App Permission List](permission-list.md). For details about whether a permission can be enabled via the ACL, see [Application Permission List](permission-list.md).
### Using the ACL ### Using the ACL
If the permission required by an app has a higher level than the app's APL, you can use the ACL to grant the permission required. If the permission required by an application has a higher level than the application's APL, you can use the ACL to grant the permission required.
In addition to the preceding [authorization processes](#authorization-processes), you must declare the ACL. In addition to the preceding [authorization processes](#authorization-processes), you must declare the ACL.
That is, you need to declare the required permissions in the app's configuration file, and [declare the ACL](accesstoken-guidelines.md#declaring-permissions-in-the-acl) in the app's profile. The subsequent steps of authorization are the same. That is, you need to declare the required permissions in the application's configuration file, and [declare the ACL](accesstoken-guidelines.md#declaring-the-acl) in the application's profile. The subsequent authorization steps are the same.
**NOTICE** **NOTICE**
When developing an app installation package, you must declare the ACL in the **acls** field in the app's profile. Then, use the [hapsigner](hapsigntool-overview.md) tool to generate a certificate. When developing an application installation package, you must declare the ACL in the **acls** field in the application's profile. Then, use the [hapsigner](hapsigntool-overview.md) tool to generate a certificate.
> **CAUTION**<br>The method of changing the app's APL in its profile applies only to the app or service in debug mode. For a commercial app, apply for a release certificate and profile in the corresponding app market. > **CAUTION**<br>The method of changing the application's APL in its profile applies only to the application or service in debug mode. For a commercial application, apply for a release certificate and profile in the corresponding application market.
```json ```json
{ {
......
...@@ -12,7 +12,7 @@ Allows an application to access Bluetooth configurations. ...@@ -12,7 +12,7 @@ Allows an application to access Bluetooth configurations.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.DISCOVER_BLUETOOTH ## ohos.permission.DISCOVER_BLUETOOTH
...@@ -22,7 +22,7 @@ Allows an application to configure Bluetooth on a device, initiate or cancel a s ...@@ -22,7 +22,7 @@ Allows an application to configure Bluetooth on a device, initiate or cancel a s
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MANAGE_BLUETOOTH ## ohos.permission.MANAGE_BLUETOOTH
...@@ -32,7 +32,7 @@ Allows an application to pair with a Bluetooth device and access the contacts or ...@@ -32,7 +32,7 @@ Allows an application to pair with a Bluetooth device and access the contacts or
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.INTERNET ## ohos.permission.INTERNET
...@@ -42,7 +42,7 @@ Allows an application to access the Internet. ...@@ -42,7 +42,7 @@ Allows an application to access the Internet.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MODIFY_AUDIO_SETTINGS ## ohos.permission.MODIFY_AUDIO_SETTINGS
...@@ -52,7 +52,7 @@ Allows an application to modify audio settings. ...@@ -52,7 +52,7 @@ Allows an application to modify audio settings.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ACCESS_NOTIFICATION_POLICY ## ohos.permission.ACCESS_NOTIFICATION_POLICY
...@@ -66,13 +66,13 @@ Allows an application to access the notification policy on the device. ...@@ -66,13 +66,13 @@ Allows an application to access the notification policy on the device.
## ohos.permission.GET_TELEPHONY_STATE ## ohos.permission.GET_TELEPHONY_STATE
Allows an application to read telephony information. Allows an application to read telephony information.
**Permission level**: system_basic **Permission level**: system_basic
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.REQUIRE_FORM ## ohos.permission.REQUIRE_FORM
...@@ -82,7 +82,7 @@ Allows an application to obtain the Ability Form. ...@@ -82,7 +82,7 @@ Allows an application to obtain the Ability Form.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_NETWORK_INFO ## ohos.permission.GET_NETWORK_INFO
...@@ -92,7 +92,7 @@ Allows an application to obtain network information. ...@@ -92,7 +92,7 @@ Allows an application to obtain network information.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.PLACE_CALL ## ohos.permission.PLACE_CALL
...@@ -102,7 +102,7 @@ Allows an application to make calls without starting the dialer. ...@@ -102,7 +102,7 @@ Allows an application to make calls without starting the dialer.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SET_NETWORK_INFO ## ohos.permission.SET_NETWORK_INFO
...@@ -112,7 +112,7 @@ Allows an application to set data network information. ...@@ -112,7 +112,7 @@ Allows an application to set data network information.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.REMOVE_CACHE_FILES ## ohos.permission.REMOVE_CACHE_FILES
...@@ -122,7 +122,7 @@ Allows the cache of the specified application to be cleared. ...@@ -122,7 +122,7 @@ Allows the cache of the specified application to be cleared.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.REBOOT ## ohos.permission.REBOOT
...@@ -132,7 +132,7 @@ Allows an application to restart the device. ...@@ -132,7 +132,7 @@ Allows an application to restart the device.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.RUNNING_LOCK ## ohos.permission.RUNNING_LOCK
...@@ -142,7 +142,7 @@ Allows an application to obtain a running lock. ...@@ -142,7 +142,7 @@ Allows an application to obtain a running lock.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SET_TIME ## ohos.permission.SET_TIME
...@@ -152,7 +152,7 @@ Allows an application to set the system time. ...@@ -152,7 +152,7 @@ Allows an application to set the system time.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SET_TIME_ZONE ## ohos.permission.SET_TIME_ZONE
...@@ -162,7 +162,7 @@ Allows an application to set the system time zone. ...@@ -162,7 +162,7 @@ Allows an application to set the system time zone.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.DOWNLOAD_SESSION_MANAGER ## ohos.permission.DOWNLOAD_SESSION_MANAGER
...@@ -172,7 +172,7 @@ Allows an application to manage the download sessions. ...@@ -172,7 +172,7 @@ Allows an application to manage the download sessions.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.COMMONEVENT_STICKY ## ohos.permission.COMMONEVENT_STICKY
...@@ -182,7 +182,7 @@ Allows an application to publish sticky common events. ...@@ -182,7 +182,7 @@ Allows an application to publish sticky common events.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SYSTEM_FLOAT_WINDOW ## ohos.permission.SYSTEM_FLOAT_WINDOW
...@@ -192,7 +192,7 @@ Allows an application to be displayed in a floating window on top of other appli ...@@ -192,7 +192,7 @@ Allows an application to be displayed in a floating window on top of other appli
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.PRIVACY_WINDOW ## ohos.permission.PRIVACY_WINDOW
...@@ -202,7 +202,7 @@ Allows an application to set screens that cannot be captured or recorded. ...@@ -202,7 +202,7 @@ Allows an application to set screens that cannot be captured or recorded.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.POWER_MANAGER ## ohos.permission.POWER_MANAGER
...@@ -212,7 +212,7 @@ Allows an application to hibernate or wake up the device by calling an API. ...@@ -212,7 +212,7 @@ Allows an application to hibernate or wake up the device by calling an API.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.REFRESH_USER_ACTION ## ohos.permission.REFRESH_USER_ACTION
...@@ -222,7 +222,7 @@ Allows an application to reset the screen timeout counter when a user input even ...@@ -222,7 +222,7 @@ Allows an application to reset the screen timeout counter when a user input even
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.POWER_OPTIMIZATION ## ohos.permission.POWER_OPTIMIZATION
...@@ -232,7 +232,7 @@ Allows an application to set power saving mode, obtain configuration of the powe ...@@ -232,7 +232,7 @@ Allows an application to set power saving mode, obtain configuration of the powe
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.REBOOT_RECOVERY ## ohos.permission.REBOOT_RECOVERY
...@@ -242,7 +242,7 @@ Allows an application to restart the device and enter Recovery mode. ...@@ -242,7 +242,7 @@ Allows an application to restart the device and enter Recovery mode.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MANAGE_LOCAL_ACCOUNTS ## ohos.permission.MANAGE_LOCAL_ACCOUNTS
...@@ -252,7 +252,7 @@ Allows an application to manage local user accounts. ...@@ -252,7 +252,7 @@ Allows an application to manage local user accounts.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS ## ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
...@@ -262,7 +262,7 @@ Allows access between multiple OS accounts. ...@@ -262,7 +262,7 @@ Allows access between multiple OS accounts.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.VIBRATE ## ohos.permission.VIBRATE
...@@ -272,7 +272,7 @@ Allows an application to control vibration. ...@@ -272,7 +272,7 @@ Allows an application to control vibration.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.CONNECT_IME_ABILITY ## ohos.permission.CONNECT_IME_ABILITY
...@@ -282,7 +282,7 @@ Allows an application to bind the InputMethodAbility. ...@@ -282,7 +282,7 @@ Allows an application to bind the InputMethodAbility.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.CONNECT_SCREEN_SAVER_ABILITY ## ohos.permission.CONNECT_SCREEN_SAVER_ABILITY
...@@ -292,7 +292,7 @@ Allows an application to bind the ScreenSaverAbility. ...@@ -292,7 +292,7 @@ Allows an application to bind the ScreenSaverAbility.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_SCREEN_SAVER ## ohos.permission.READ_SCREEN_SAVER
...@@ -302,7 +302,7 @@ Allows an application to read the screen saver information, such as the list of ...@@ -302,7 +302,7 @@ Allows an application to read the screen saver information, such as the list of
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.WRITE_SCREEN_SAVER ## ohos.permission.WRITE_SCREEN_SAVER
...@@ -312,7 +312,7 @@ Allows an application to modify the screen saver information, such as activating ...@@ -312,7 +312,7 @@ Allows an application to modify the screen saver information, such as activating
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SET_WALLPAPER ## ohos.permission.SET_WALLPAPER
...@@ -322,7 +322,7 @@ Allows an application to set a static wallpaper. ...@@ -322,7 +322,7 @@ Allows an application to set a static wallpaper.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_WALLPAPER ## ohos.permission.GET_WALLPAPER
...@@ -332,7 +332,7 @@ Allows an application to read wallpaper files. ...@@ -332,7 +332,7 @@ Allows an application to read wallpaper files.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.CHANGE_ABILITY_ENABLED_STATE ## ohos.permission.CHANGE_ABILITY_ENABLED_STATE
...@@ -342,7 +342,7 @@ Allows an application to enable or disable an application or component. ...@@ -342,7 +342,7 @@ Allows an application to enable or disable an application or component.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ACCESS_MISSIONS ## ohos.permission.ACCESS_MISSIONS
...@@ -352,7 +352,7 @@ Allows an application to obtain information about running processes and mission ...@@ -352,7 +352,7 @@ Allows an application to obtain information about running processes and mission
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.CLEAN_BACKGROUND_PROCESSES ## ohos.permission.CLEAN_BACKGROUND_PROCESSES
...@@ -362,7 +362,7 @@ Allows an application to clear background processes based on their bundle names. ...@@ -362,7 +362,7 @@ Allows an application to clear background processes based on their bundle names.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.KEEP_BACKGROUND_RUNNING ## ohos.permission.KEEP_BACKGROUND_RUNNING
...@@ -372,7 +372,7 @@ Allows a Service ability to keep running in the background. ...@@ -372,7 +372,7 @@ Allows a Service ability to keep running in the background.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.UPDATE_CONFIGURATION ## ohos.permission.UPDATE_CONFIGURATION
...@@ -382,7 +382,7 @@ Allows an application to modify system settings. ...@@ -382,7 +382,7 @@ Allows an application to modify system settings.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.UPDATE_SYSTEM ## ohos.permission.UPDATE_SYSTEM
...@@ -392,7 +392,7 @@ Allows an application to call the update APIs. ...@@ -392,7 +392,7 @@ Allows an application to call the update APIs.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.FACTORY_RESET ## ohos.permission.FACTORY_RESET
...@@ -402,7 +402,7 @@ Allows an application to call the API for restoring factory settings. ...@@ -402,7 +402,7 @@ Allows an application to call the API for restoring factory settings.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GRANT_SENSITIVE_PERMISSIONS ## ohos.permission.GRANT_SENSITIVE_PERMISSIONS
...@@ -412,7 +412,7 @@ Allows an application to grant sensitive permissions to other applications. ...@@ -412,7 +412,7 @@ Allows an application to grant sensitive permissions to other applications.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.REVOKE_SENSITIVE_PERMISSIONS ## ohos.permission.REVOKE_SENSITIVE_PERMISSIONS
...@@ -422,7 +422,7 @@ Allows an application to revoke sensitive permissions granted to other applicati ...@@ -422,7 +422,7 @@ Allows an application to revoke sensitive permissions granted to other applicati
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_SENSITIVE_PERMISSIONS ## ohos.permission.GET_SENSITIVE_PERMISSIONS
...@@ -432,7 +432,7 @@ Allows an application to obtain the sensitive permissions that have been granted ...@@ -432,7 +432,7 @@ Allows an application to obtain the sensitive permissions that have been granted
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION ## ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
...@@ -442,7 +442,7 @@ Allows an application to set attributes for the applications of other users. ...@@ -442,7 +442,7 @@ Allows an application to set attributes for the applications of other users.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.LISTEN_BUNDLE_CHANGE ## ohos.permission.LISTEN_BUNDLE_CHANGE
...@@ -452,7 +452,7 @@ Allows an application to listen for changes in other applications, when they are ...@@ -452,7 +452,7 @@ Allows an application to listen for changes in other applications, when they are
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_BUNDLE_INFO ## ohos.permission.GET_BUNDLE_INFO
...@@ -462,7 +462,7 @@ Allows an application to query information about another application. This permi ...@@ -462,7 +462,7 @@ Allows an application to query information about another application. This permi
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_BUNDLE_INFO_PRIVILEGED ## ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
...@@ -472,7 +472,7 @@ Allows an application to query information about other applications at the same ...@@ -472,7 +472,7 @@ Allows an application to query information about other applications at the same
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ACCELEROMETER ## ohos.permission.ACCELEROMETER
...@@ -482,7 +482,7 @@ Allows an application to read data from an acceleration sensor, uncalibrated acc ...@@ -482,7 +482,7 @@ Allows an application to read data from an acceleration sensor, uncalibrated acc
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GYROSCOPE ## ohos.permission.GYROSCOPE
...@@ -492,7 +492,7 @@ Allows an application to read data from a gyroscope sensor or uncalibrated gyros ...@@ -492,7 +492,7 @@ Allows an application to read data from a gyroscope sensor or uncalibrated gyros
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.INSTALL_BUNDLE ## ohos.permission.INSTALL_BUNDLE
...@@ -502,7 +502,7 @@ Allows an application to install and uninstall other applications. ...@@ -502,7 +502,7 @@ Allows an application to install and uninstall other applications.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MANAGE_SHORTCUTS ## ohos.permission.MANAGE_SHORTCUTS
...@@ -512,7 +512,7 @@ Allows an application to query and start shortcuts of other applications. ...@@ -512,7 +512,7 @@ Allows an application to query and start shortcuts of other applications.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.radio.ACCESS_FM_AM ## ohos.permission.radio.ACCESS_FM_AM
...@@ -522,7 +522,7 @@ Allows an application to access radio services. ...@@ -522,7 +522,7 @@ Allows an application to access radio services.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SET_TELEPHONY_STATE ## ohos.permission.SET_TELEPHONY_STATE
...@@ -532,7 +532,7 @@ Allows an application to change the telephone state. ...@@ -532,7 +532,7 @@ Allows an application to change the telephone state.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.START_ABILITIES_FROM_BACKGROUND ## ohos.permission.START_ABILITIES_FROM_BACKGROUND
...@@ -542,7 +542,7 @@ Allows an application to start or access other components from the background. ...@@ -542,7 +542,7 @@ Allows an application to start or access other components from the background.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.BUNDLE_ACTIVE_INFO ## ohos.permission.BUNDLE_ACTIVE_INFO
...@@ -552,7 +552,7 @@ Allows an application to obtain how long other applications have been running in ...@@ -552,7 +552,7 @@ Allows an application to obtain how long other applications have been running in
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.START_INVISIBLE_ABILITY ## ohos.permission.START_INVISIBLE_ABILITY
...@@ -562,7 +562,7 @@ Allows an application to start an invisible ability. ...@@ -562,7 +562,7 @@ Allows an application to start an invisible ability.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.sec.ACCESS_UDID ## ohos.permission.sec.ACCESS_UDID
...@@ -572,7 +572,7 @@ Allows an application to obtain the Unified Device ID (UDID). ...@@ -572,7 +572,7 @@ Allows an application to obtain the Unified Device ID (UDID).
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.LAUNCH_DATA_PRIVACY_CENTER ## ohos.permission.LAUNCH_DATA_PRIVACY_CENTER
...@@ -582,7 +582,7 @@ Allows an application to switch from its privacy statement page to the <b>Data & ...@@ -582,7 +582,7 @@ Allows an application to switch from its privacy statement page to the <b>Data &
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MANAGE_MEDIA_RESOURCES ## ohos.permission.MANAGE_MEDIA_RESOURCES
...@@ -592,7 +592,7 @@ Allows an application to obtain and manage the media resources that are being pl ...@@ -592,7 +592,7 @@ Allows an application to obtain and manage the media resources that are being pl
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.PUBLISH_AGENT_REMINDER ## ohos.permission.PUBLISH_AGENT_REMINDER
...@@ -602,7 +602,7 @@ Allows an application to use agent-powered reminders. ...@@ -602,7 +602,7 @@ Allows an application to use agent-powered reminders.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.CONTROL_TASK_SYNC_ANIMATOR ## ohos.permission.CONTROL_TASK_SYNC_ANIMATOR
...@@ -612,7 +612,7 @@ Allows an application to use sync task animations. ...@@ -612,7 +612,7 @@ Allows an application to use sync task animations.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.INPUT_MONITORING ## ohos.permission.INPUT_MONITORING
...@@ -622,7 +622,7 @@ Allows an application to listen for input events. Only the system signed applica ...@@ -622,7 +622,7 @@ Allows an application to listen for input events. Only the system signed applica
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MANAGE_MISSIONS ## ohos.permission.MANAGE_MISSIONS
...@@ -632,7 +632,7 @@ Allows an application to manage ability mission stacks. ...@@ -632,7 +632,7 @@ Allows an application to manage ability mission stacks.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.NOTIFICATION_CONTROLLER ## ohos.permission.NOTIFICATION_CONTROLLER
...@@ -642,7 +642,7 @@ Allows an application to manage and subscribe to notifications. ...@@ -642,7 +642,7 @@ Allows an application to manage and subscribe to notifications.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.CONNECTIVITY_INTERNAL ## ohos.permission.CONNECTIVITY_INTERNAL
...@@ -652,7 +652,7 @@ Allows an application to obtain network information or modify network settings. ...@@ -652,7 +652,7 @@ Allows an application to obtain network information or modify network settings.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SET_ABILITY_CONTROLLER ## ohos.permission.SET_ABILITY_CONTROLLER
...@@ -662,7 +662,7 @@ Allows an application to set the start and stop of an ability. ...@@ -662,7 +662,7 @@ Allows an application to set the start and stop of an ability.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.USE_USER_IDM ## ohos.permission.USE_USER_IDM
...@@ -692,7 +692,7 @@ Allows an application to use biometric recognition for identity authentication. ...@@ -692,7 +692,7 @@ Allows an application to use biometric recognition for identity authentication.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ACCESS_USER_AUTH_INTERNAL ## ohos.permission.ACCESS_USER_AUTH_INTERNAL
...@@ -722,7 +722,7 @@ Allows an application to obtain running status information. ...@@ -722,7 +722,7 @@ Allows an application to obtain running status information.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.CLEAN_APPLICATION_DATA ## ohos.permission.CLEAN_APPLICATION_DATA
...@@ -732,7 +732,7 @@ Allows an application to clear application data. ...@@ -732,7 +732,7 @@ Allows an application to clear application data.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.RUNNING_STATE_OBSERVER ## ohos.permission.RUNNING_STATE_OBSERVER
...@@ -742,7 +742,7 @@ Allows an application to observe the application status. ...@@ -742,7 +742,7 @@ Allows an application to observe the application status.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.CAPTURE_SCREEN ## ohos.permission.CAPTURE_SCREEN
...@@ -752,7 +752,7 @@ Allows an application to take screenshots. ...@@ -752,7 +752,7 @@ Allows an application to take screenshots.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_WIFI_INFO ## ohos.permission.GET_WIFI_INFO
...@@ -762,7 +762,7 @@ Allows an application to obtain WLAN information. ...@@ -762,7 +762,7 @@ Allows an application to obtain WLAN information.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_WIFI_INFO_INTERNAL ## ohos.permission.GET_WIFI_INFO_INTERNAL
...@@ -772,7 +772,7 @@ Allows an application to obtain WLAN information. ...@@ -772,7 +772,7 @@ Allows an application to obtain WLAN information.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SET_WIFI_INFO ## ohos.permission.SET_WIFI_INFO
...@@ -782,7 +782,7 @@ Allows an application to set WLAN devices. ...@@ -782,7 +782,7 @@ Allows an application to set WLAN devices.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_WIFI_PEERS_MAC ## ohos.permission.GET_WIFI_PEERS_MAC
...@@ -792,7 +792,7 @@ Allows an application to obtain the MAC address of the peer WLAN or Bluetooth de ...@@ -792,7 +792,7 @@ Allows an application to obtain the MAC address of the peer WLAN or Bluetooth de
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_WIFI_LOCAL_MAC ## ohos.permission.GET_WIFI_LOCAL_MAC
...@@ -802,7 +802,7 @@ Allows an application to obtain the MAC address of the local WLAN or Bluetooth d ...@@ -802,7 +802,7 @@ Allows an application to obtain the MAC address of the local WLAN or Bluetooth d
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_WIFI_CONFIG ## ohos.permission.GET_WIFI_CONFIG
...@@ -812,7 +812,7 @@ Allows an application to obtain the WLAN configuration. ...@@ -812,7 +812,7 @@ Allows an application to obtain the WLAN configuration.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SET_WIFI_CONFIG ## ohos.permission.SET_WIFI_CONFIG
...@@ -822,7 +822,7 @@ Allows an application to set WLAN information. ...@@ -822,7 +822,7 @@ Allows an application to set WLAN information.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MANAGE_WIFI_CONNECTION ## ohos.permission.MANAGE_WIFI_CONNECTION
...@@ -832,7 +832,7 @@ Allows an application to manage WLAN connections. ...@@ -832,7 +832,7 @@ Allows an application to manage WLAN connections.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MANAGE_WIFI_HOTSPOT ## ohos.permission.MANAGE_WIFI_HOTSPOT
...@@ -842,7 +842,7 @@ Allows an application to enable or disable Wi-Fi hotspots. ...@@ -842,7 +842,7 @@ Allows an application to enable or disable Wi-Fi hotspots.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_ALL_APP_ACCOUNTS ## ohos.permission.GET_ALL_APP_ACCOUNTS
...@@ -862,7 +862,7 @@ Allows an application to modify security settings. ...@@ -862,7 +862,7 @@ Allows an application to modify security settings.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_DFX_SYSEVENT ## ohos.permission.READ_DFX_SYSEVENT
...@@ -872,7 +872,7 @@ Allows an application to access system event logging data. ...@@ -872,7 +872,7 @@ Allows an application to access system event logging data.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN ## ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
...@@ -882,7 +882,7 @@ Allows an application to activate the device administrator app. ...@@ -882,7 +882,7 @@ Allows an application to activate the device administrator app.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SET_ENTERPRISE_INFO ## ohos.permission.SET_ENTERPRISE_INFO
...@@ -892,7 +892,7 @@ Allows the device administrator application to set enterprise information. ...@@ -892,7 +892,7 @@ Allows the device administrator application to set enterprise information.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT ## ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
...@@ -902,7 +902,7 @@ Allows the device administrator application to subscribe to management events. ...@@ -902,7 +902,7 @@ Allows the device administrator application to subscribe to management events.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ENTERPRISE_SET_DATETIME ## ohos.permission.ENTERPRISE_SET_DATETIME
...@@ -912,7 +912,7 @@ Allows the device administrator application to set the system time. ...@@ -912,7 +912,7 @@ Allows the device administrator application to set the system time.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ENTERPRISE_GET_DEVICE_INFO ## ohos.permission.ENTERPRISE_GET_DEVICE_INFO
...@@ -922,7 +922,7 @@ Allows the device administrator application to obtain device information. ...@@ -922,7 +922,7 @@ Allows the device administrator application to obtain device information.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ENTERPRISE_RESET_DEVICE ## ohos.permission.ENTERPRISE_RESET_DEVICE
...@@ -932,7 +932,37 @@ Allows the device administrator to restore factory settings of the device. ...@@ -932,7 +932,37 @@ Allows the device administrator to restore factory settings of the device.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ENTERPRISE_SET_WIFI
Allows a device administrator application to set and query Wi-Fi information.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.ENTERPRISE_GET_NETWORK_INFO
Allows a device administrator application to query network information.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.ENTERPRISE_SET_ACCOUNT_POLICY
Allows the device administrator to set account management policies.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.NFC_TAG ## ohos.permission.NFC_TAG
...@@ -962,7 +992,7 @@ Allows a system application to access the permission usage records. ...@@ -962,7 +992,7 @@ Allows a system application to access the permission usage records.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.NOTIFICATION_AGENT_CONTROLLER ## ohos.permission.NOTIFICATION_AGENT_CONTROLLER
...@@ -972,7 +1002,7 @@ Allows an application to send agent-powered notifications. ...@@ -972,7 +1002,7 @@ Allows an application to send agent-powered notifications.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ANSWER_CALL ## ohos.permission.ANSWER_CALL
...@@ -982,7 +1012,7 @@ Allows an application to answer incoming calls. ...@@ -982,7 +1012,7 @@ Allows an application to answer incoming calls.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_CALENDAR ## ohos.permission.READ_CALENDAR
...@@ -992,7 +1022,7 @@ Allows an application to read calendar data. ...@@ -992,7 +1022,7 @@ Allows an application to read calendar data.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_CALL_LOG ## ohos.permission.READ_CALL_LOG
...@@ -1002,7 +1032,7 @@ Allows an application to read call logs. ...@@ -1002,7 +1032,7 @@ Allows an application to read call logs.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_CELL_MESSAGES ## ohos.permission.READ_CELL_MESSAGES
...@@ -1012,7 +1042,7 @@ Allows an application to read cell broadcast messages received by the device. ...@@ -1012,7 +1042,7 @@ Allows an application to read cell broadcast messages received by the device.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_CONTACTS ## ohos.permission.READ_CONTACTS
...@@ -1022,7 +1052,7 @@ Allows an application to read contacts. ...@@ -1022,7 +1052,7 @@ Allows an application to read contacts.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_MESSAGES ## ohos.permission.READ_MESSAGES
...@@ -1032,7 +1062,7 @@ Allows an application to read messages. ...@@ -1032,7 +1062,7 @@ Allows an application to read messages.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.RECEIVE_MMS ## ohos.permission.RECEIVE_MMS
...@@ -1042,7 +1072,7 @@ Allows an application to receive and process MMS messages. ...@@ -1042,7 +1072,7 @@ Allows an application to receive and process MMS messages.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.RECEIVE_SMS ## ohos.permission.RECEIVE_SMS
...@@ -1052,7 +1082,7 @@ Allows an application to receive and process SMS messages. ...@@ -1052,7 +1082,7 @@ Allows an application to receive and process SMS messages.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.RECEIVE_WAP_MESSAGES ## ohos.permission.RECEIVE_WAP_MESSAGES
...@@ -1062,7 +1092,7 @@ Allows an application to receive and process WAP messages. ...@@ -1062,7 +1092,7 @@ Allows an application to receive and process WAP messages.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MICROPHONE ## ohos.permission.MICROPHONE
...@@ -1072,7 +1102,7 @@ Allows an application to access the microphone. ...@@ -1072,7 +1102,7 @@ Allows an application to access the microphone.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SEND_MESSAGES ## ohos.permission.SEND_MESSAGES
...@@ -1082,7 +1112,7 @@ Allows an application to send messages. ...@@ -1082,7 +1112,7 @@ Allows an application to send messages.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.WRITE_CALENDAR ## ohos.permission.WRITE_CALENDAR
...@@ -1092,7 +1122,7 @@ Allows an application to add, remove, and modify calendar events. ...@@ -1092,7 +1122,7 @@ Allows an application to add, remove, and modify calendar events.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.WRITE_CALL_LOG ## ohos.permission.WRITE_CALL_LOG
...@@ -1102,7 +1132,7 @@ Allows an application to add, remove, and modify call logs. ...@@ -1102,7 +1132,7 @@ Allows an application to add, remove, and modify call logs.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.WRITE_CONTACTS ## ohos.permission.WRITE_CONTACTS
...@@ -1112,7 +1142,7 @@ Allows an application to add, remove, and modify contacts. ...@@ -1112,7 +1142,7 @@ Allows an application to add, remove, and modify contacts.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.DISTRIBUTED_DATASYNC ## ohos.permission.DISTRIBUTED_DATASYNC
...@@ -1122,7 +1152,7 @@ Allows an application to exchange data with other devices. ...@@ -1122,7 +1152,7 @@ Allows an application to exchange data with other devices.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MANAGE_VOICEMAIL ## ohos.permission.MANAGE_VOICEMAIL
...@@ -1132,7 +1162,7 @@ Allows an application to leave messages in the voice mailbox. ...@@ -1132,7 +1162,7 @@ Allows an application to leave messages in the voice mailbox.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.LOCATION_IN_BACKGROUND ## ohos.permission.LOCATION_IN_BACKGROUND
...@@ -1152,7 +1182,9 @@ Allows an application to obtain the device location. ...@@ -1152,7 +1182,9 @@ Allows an application to obtain the device location.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
**Application conditions**: The applications developed using the SDK earlier than API version 9 can directly apply for this permission. For the applications developed using the SDK of API version 9 or later, you need to apply for [ohos.permission.APPROXIMATELY_LOCATION](#ohospermissionapproximately_location) before applying for this permission.
## ohos.permission.APPROXIMATELY_LOCATION ## ohos.permission.APPROXIMATELY_LOCATION
...@@ -1164,6 +1196,8 @@ Allows an application to obtain the approximate location information of a device ...@@ -1164,6 +1196,8 @@ Allows an application to obtain the approximate location information of a device
**Enable ACL**: FALSE **Enable ACL**: FALSE
**Application conditions**: Only applications developed using the SDK of API version 9 or later can apply for this permission.
## ohos.permission.MEDIA_LOCATION ## ohos.permission.MEDIA_LOCATION
Allows an application to access geographical locations in the user's media file. Allows an application to access geographical locations in the user's media file.
...@@ -1172,7 +1206,7 @@ Allows an application to access geographical locations in the user's media file. ...@@ -1172,7 +1206,7 @@ Allows an application to access geographical locations in the user's media file.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.CAMERA ## ohos.permission.CAMERA
...@@ -1182,7 +1216,7 @@ Allows an application to use the camera to take photos and record videos. ...@@ -1182,7 +1216,7 @@ Allows an application to use the camera to take photos and record videos.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_MEDIA ## ohos.permission.READ_MEDIA
...@@ -1192,7 +1226,7 @@ Allows an application to read media files from the user's external storage. ...@@ -1192,7 +1226,7 @@ Allows an application to read media files from the user's external storage.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.WRITE_MEDIA ## ohos.permission.WRITE_MEDIA
...@@ -1202,7 +1236,7 @@ Allows an application to read media files from and write media files into the us ...@@ -1202,7 +1236,7 @@ Allows an application to read media files from and write media files into the us
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ACTIVITY_MOTION ## ohos.permission.ACTIVITY_MOTION
...@@ -1212,7 +1246,7 @@ Allows an application to read the current workout status of the user. ...@@ -1212,7 +1246,7 @@ Allows an application to read the current workout status of the user.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_HEALTH_DATA ## ohos.permission.READ_HEALTH_DATA
...@@ -1222,7 +1256,7 @@ Allows an application to read the health data of the user. ...@@ -1222,7 +1256,7 @@ Allows an application to read the health data of the user.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.GET_DEFAULT_APPLICATION ## ohos.permission.GET_DEFAULT_APPLICATION
...@@ -1232,7 +1266,7 @@ Allows an application to query default applications. ...@@ -1232,7 +1266,7 @@ Allows an application to query default applications.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.SET_DEFAULT_APPLICATION ## ohos.permission.SET_DEFAULT_APPLICATION
...@@ -1242,7 +1276,7 @@ Allows an application to set and reset default applications. ...@@ -1242,7 +1276,7 @@ Allows an application to set and reset default applications.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MANAGE_DISPOSED_APP_STATUS ## ohos.permission.MANAGE_DISPOSED_APP_STATUS
...@@ -1252,7 +1286,7 @@ Allows an application to set and query the application handling state. ...@@ -1252,7 +1286,7 @@ Allows an application to set and query the application handling state.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ACCESS_IDS ## ohos.permission.ACCESS_IDS
...@@ -1262,7 +1296,7 @@ Allows an application to query the unique identifier of a device. ...@@ -1262,7 +1296,7 @@ Allows an application to query the unique identifier of a device.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.DUMP ## ohos.permission.DUMP
...@@ -1272,7 +1306,7 @@ Allows the basic system information and SA service information to be exported. ...@@ -1272,7 +1306,7 @@ Allows the basic system information and SA service information to be exported.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.DISTRIBUTED_SOFTBUS_CENTER ## ohos.permission.DISTRIBUTED_SOFTBUS_CENTER
...@@ -1292,7 +1326,7 @@ Allows configuration and management of the permissions on .dlp files. ...@@ -1292,7 +1326,7 @@ Allows configuration and management of the permissions on .dlp files.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.PROVISIONING_MESSAGE ## ohos.permission.PROVISIONING_MESSAGE
...@@ -1302,7 +1336,7 @@ Allows the Super Device Manager application to be activated. ...@@ -1302,7 +1336,7 @@ Allows the Super Device Manager application to be activated.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ACCESS_SYSTEM_SETTINGS ## ohos.permission.ACCESS_SYSTEM_SETTINGS
...@@ -1312,7 +1346,7 @@ Allows an application to access or start system **Settings**. ...@@ -1312,7 +1346,7 @@ Allows an application to access or start system **Settings**.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_IMAGEVIDEO ## ohos.permission.READ_IMAGEVIDEO
...@@ -1322,7 +1356,7 @@ Allows access to the images or video files in a user's directory. ...@@ -1322,7 +1356,7 @@ Allows access to the images or video files in a user's directory.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_AUDIO ## ohos.permission.READ_AUDIO
...@@ -1332,7 +1366,7 @@ Allows access to the audio files in a user's directory. ...@@ -1332,7 +1366,7 @@ Allows access to the audio files in a user's directory.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.READ_DOCUMENT ## ohos.permission.READ_DOCUMENT
...@@ -1342,7 +1376,7 @@ Allows access to the files in a user's directory. ...@@ -1342,7 +1376,7 @@ Allows access to the files in a user's directory.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.WRITE_IMAGEVIDEO ## ohos.permission.WRITE_IMAGEVIDEO
...@@ -1352,7 +1386,7 @@ Allows modification to the images or video files in a user's directory. ...@@ -1352,7 +1386,7 @@ Allows modification to the images or video files in a user's directory.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.WRITE_AUDIO ## ohos.permission.WRITE_AUDIO
...@@ -1362,7 +1396,7 @@ Audio modification to the audio files in a user's directory. ...@@ -1362,7 +1396,7 @@ Audio modification to the audio files in a user's directory.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.WRITE_DOCUMENT ## ohos.permission.WRITE_DOCUMENT
...@@ -1372,7 +1406,7 @@ Allows modification to the files in a user's directory. ...@@ -1372,7 +1406,7 @@ Allows modification to the files in a user's directory.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ABILITY_BACKGROUND_COMMUNICATION ## ohos.permission.ABILITY_BACKGROUND_COMMUNICATION
...@@ -1382,7 +1416,7 @@ Allows an application to start the Ability component in the background and estab ...@@ -1382,7 +1416,7 @@ Allows an application to start the Ability component in the background and estab
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.securityguard.REPORT_SECURITY_INFO ## ohos.permission.securityguard.REPORT_SECURITY_INFO
...@@ -1402,7 +1436,7 @@ Allows an application to obtain the device risk status. ...@@ -1402,7 +1436,7 @@ Allows an application to obtain the device risk status.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.securityguard.REQUEST_SECURITY_EVENT_INFO ## ohos.permission.securityguard.REQUEST_SECURITY_EVENT_INFO
...@@ -1462,7 +1496,7 @@ Allows an application to to access the Ability of the push service. ...@@ -1462,7 +1496,7 @@ Allows an application to to access the Ability of the push service.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.RECEIVER_STARTUP_COMPLETED ## ohos.permission.RECEIVER_STARTUP_COMPLETED
...@@ -1492,7 +1526,7 @@ Allows an application to read all calendar information. ...@@ -1492,7 +1526,7 @@ Allows an application to read all calendar information.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.WRITE_WHOLE_CALENDAR ## ohos.permission.WRITE_WHOLE_CALENDAR
...@@ -1502,7 +1536,7 @@ Allows an application to add, remove, or change all calendar events. ...@@ -1502,7 +1536,7 @@ Allows an application to add, remove, or change all calendar events.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ENFORCE_USER_IAM ## ohos.permission.ENFORCE_USER_IAM
...@@ -1512,7 +1546,7 @@ Allows an SA to delete user information from the IAM subsystem without a token. ...@@ -1512,7 +1546,7 @@ Allows an SA to delete user information from the IAM subsystem without a token.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ACCESS_AUTH_RESPOOL ## ohos.permission.ACCESS_AUTH_RESPOOL
...@@ -1522,7 +1556,7 @@ Allows an SA to register the executor. ...@@ -1522,7 +1556,7 @@ Allows an SA to register the executor.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MOUNT_UNMOUNT_MANAGER ## ohos.permission.MOUNT_UNMOUNT_MANAGER
...@@ -1552,7 +1586,7 @@ Allows an application to call the interfaces of the Storage Manager service to q ...@@ -1552,7 +1586,7 @@ Allows an application to call the interfaces of the Storage Manager service to q
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.BACKUP ## ohos.permission.BACKUP
...@@ -1562,7 +1596,7 @@ Allows an application to have backup and restore capabilities. ...@@ -1562,7 +1596,7 @@ Allows an application to have backup and restore capabilities.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.FILE_ACCESS_MANAGER ## ohos.permission.FILE_ACCESS_MANAGER
...@@ -1572,7 +1606,7 @@ Allows a file management application to access user data files through the FAF. ...@@ -1572,7 +1606,7 @@ Allows a file management application to access user data files through the FAF.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.MANAGE_AUDIO_CONFIG ## ohos.permission.MANAGE_AUDIO_CONFIG
...@@ -1582,7 +1616,7 @@ Allows an application to to mute microphones globally. ...@@ -1582,7 +1616,7 @@ Allows an application to to mute microphones globally.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ACCESS_SERVICE_DM ## ohos.permission.ACCESS_SERVICE_DM
...@@ -1592,7 +1626,7 @@ Allows a system application to obtain the authentication and networking capabili ...@@ -1592,7 +1626,7 @@ Allows a system application to obtain the authentication and networking capabili
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.APP_TRACKING_CONSENT ## ohos.permission.APP_TRACKING_CONSENT
...@@ -1602,7 +1636,7 @@ Allows an application to read advertisement identifiers. ...@@ -1602,7 +1636,7 @@ Allows an application to read advertisement identifiers.
**Authorization mode**: user_grant **Authorization mode**: user_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.RUN_ANY_CODE ## ohos.permission.RUN_ANY_CODE
...@@ -1612,7 +1646,7 @@ Allows an application to run unsigned code. ...@@ -1612,7 +1646,7 @@ Allows an application to run unsigned code.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.PUBLISH_SYSTEM_COMMON_EVENT ## ohos.permission.PUBLISH_SYSTEM_COMMON_EVENT
...@@ -1622,7 +1656,7 @@ Allows an application to publish system common events. ...@@ -1622,7 +1656,7 @@ Allows an application to publish system common events.
**Authorization mode**: system_grant **Authorization mode**: system_grant
**Enable ACL**: TRUE **Enable via ACL**: TRUE
## ohos.permission.ACCESS_SCREEN_LOCK_INNER ## ohos.permission.ACCESS_SCREEN_LOCK_INNER
......
...@@ -8,10 +8,12 @@ Create a **\<Web>** component in the .ets file under **main/ets/entryability/pag ...@@ -8,10 +8,12 @@ Create a **\<Web>** component in the .ets file under **main/ets/entryability/pag
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview';
@Entry @Entry
@Component @Component
struct WebComponent { struct WebComponent {
controller: WebController = new WebController(); controller: web_webview.WebviewController = new web_webview.WebviewController();
build() { build() {
Column() { Column() {
Web({ src: 'https://www.example.com', controller: this.controller }) Web({ src: 'https://www.example.com', controller: this.controller })
...@@ -26,11 +28,13 @@ When using the **\<Web>** component, you must specify the styles and attributes. ...@@ -26,11 +28,13 @@ When using the **\<Web>** component, you must specify the styles and attributes.
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview';
@Entry @Entry
@Component @Component
struct WebComponent { struct WebComponent {
fileAccess: boolean = true; fileAccess: boolean = true;
controller: WebController = new WebController(); controller: web_webview.WebviewController = new web_webview.WebviewController();
build() { build() {
Column() { Column() {
Text('Hello world!') Text('Hello world!')
...@@ -54,13 +58,15 @@ Add the **onProgressChange** event for the **\<Web>** component, which is trigge ...@@ -54,13 +58,15 @@ Add the **onProgressChange** event for the **\<Web>** component, which is trigge
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview';
@Entry @Entry
@Component @Component
struct WebComponent { struct WebComponent {
@State progress: number = 0; @State progress: number = 0;
@State hideProgress: boolean = true; @State hideProgress: boolean = true;
fileAccess: boolean = true; fileAccess: boolean = true;
controller: WebController = new WebController(); controller: web_webview.WebviewController = new web_webview.WebviewController();
build() { build() {
Column() { Column() {
Text('Hello world!') Text('Hello world!')
...@@ -93,14 +99,17 @@ Add the **runJavaScript** method to the **onPageEnd** event. The **onPageEnd** e ...@@ -93,14 +99,17 @@ Add the **runJavaScript** method to the **onPageEnd** event. The **onPageEnd** e
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview';
@Entry @Entry
@Component @Component
struct WebComponent { struct WebComponent {
@State progress: number = 0; @State progress: number = 0;
@State hideProgress: boolean = true; @State hideProgress: boolean = true;
@State webResult: string = ''
fileAccess: boolean = true; fileAccess: boolean = true;
// Define the controller for the \<Web> component. // Define the controller for the \<Web> component.
controller: WebController = new WebController(); controller: web_webview.WebviewController = new web_webview.WebviewController();
build() { build() {
Column() { Column() {
Text('Hello world!') Text('Hello world!')
...@@ -124,8 +133,23 @@ struct WebComponent { ...@@ -124,8 +133,23 @@ struct WebComponent {
}) })
.onPageEnd(e => { .onPageEnd(e => {
// test() is defined in index.html. // test() is defined in index.html.
this.controller.runJavaScript({ script: 'test()' }); try {
console.info('url: ', e.url); this.controller.runJavaScript(
'test()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
this.webResult = result
console.info(`The test() return value is: ${result}`)
}
});
console.info('url: ', e.url);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
}) })
Text('End') Text('End')
.fontSize(20) .fontSize(20)
...@@ -160,10 +184,12 @@ The configuration procedure is as follows: ...@@ -160,10 +184,12 @@ The configuration procedure is as follows:
1. Set the **webDebuggingAccess** attribute of the **\<Web>** component to **true**. 1. Set the **webDebuggingAccess** attribute of the **\<Web>** component to **true**.
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview';
@Entry @Entry
@Component @Component
struct WebComponent { struct WebComponent {
controller: WebController = new WebController() controller: web_webview.WebviewController = new web_webview.WebviewController();
build() { build() {
Column() { Column() {
Web({ src: 'www.example.com', controller: this.controller }) Web({ src: 'www.example.com', controller: this.controller })
...@@ -189,20 +215,30 @@ In this example, you'll implement a **\<Web>** component where videos can be pla ...@@ -189,20 +215,30 @@ In this example, you'll implement a **\<Web>** component where videos can be pla
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview';
@Entry @Entry
@Component @Component
struct WebComponent { struct WebComponent {
controller: WebController = new WebController(); controller: web_webview.WebviewController = new web_webview.WebviewController();
build() { build() {
Column() { Column() {
Row() { Row() {
Button('onActive').onClick(() => { Button('onActive').onClick(() => {
console.info("Web Component onActive"); console.info("Web Component onActive");
this.controller.onActive(); try {
this.controller.onActive();
} catch (error) {
console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
}
}) })
Button('onInactive').onClick(() => { Button('onInactive').onClick(() => {
console.info("Web Component onInactive"); console.info("Web Component onInactive");
this.controller.onInactive(); try {
this.controller.onInactive();
} catch (error) {
console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
}
}) })
} }
Web({ src: $rawfile('index.html'), controller: this.controller }) Web({ src: $rawfile('index.html'), controller: this.controller })
......
...@@ -65,6 +65,7 @@ ohos_shared_library("helloworld") { ...@@ -65,6 +65,7 @@ ohos_shared_library("helloworld") {
# Sanitizer variables # Sanitizer variables
cfi = [boolean] cfi = [boolean]
cfi_cross_dso = [boolean] # CFI: shared library support.
scs = [boolean] scs = [boolean]
scudo = [] scudo = []
ubsan = [] ubsan = []
...@@ -106,6 +107,7 @@ ohos_static_library("helloworld") { ...@@ -106,6 +107,7 @@ ohos_static_library("helloworld") {
# Sanitizer variables # Sanitizer variables
cfi = [boolean] cfi = [boolean]
cfi_cross_dso = [boolean] # CFI: shared library support.
scs = [boolean] scs = [boolean]
scudo = [] scudo = []
ubsan = [] ubsan = []
...@@ -138,6 +140,7 @@ ohos_executable("helloworld") { ...@@ -138,6 +140,7 @@ ohos_executable("helloworld") {
# Sanitizer variables # Sanitizer variables
cfi = [boolean] cfi = [boolean]
cfi_cross_dso = [boolean] # CFI: shared library support.
scs = [boolean] scs = [boolean]
scudo = [] scudo = []
ubsan = [] ubsan = []
...@@ -181,6 +184,7 @@ ohos_source_set("helloworld") { ...@@ -181,6 +184,7 @@ ohos_source_set("helloworld") {
# Sanitizer variables # Sanitizer variables
cfi = [boolean] cfi = [boolean]
cfi_cross_dso = [boolean] # CFI: shared library support.
scs = [boolean] scs = [boolean]
scudo = [] scudo = []
ubsan = [] ubsan = []
......
...@@ -72,6 +72,7 @@ Sanitizer configuration example: ...@@ -72,6 +72,7 @@ Sanitizer configuration example:
ohos_shared_library("example") { ohos_shared_library("example") {
sanitize = { sanitize = {
cfi = true cfi = true
cfi_cross_dso = true # CFI: shared library support.
integer_overflow = true integer_overflow = true
debug = true # Optional. The debug mode is disabled by default. debug = true # Optional. The debug mode is disabled by default.
blocklist = "./blocklist.txt" # Optional. Enter the path of the blocklist. blocklist = "./blocklist.txt" # Optional. Enter the path of the blocklist.
......
# Upload and Download Subsystem Changelog
## cl.request.2 request API Change
Deleted the beta APIs in API version 9:
1. function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback\<DownloadTask>): void;
2. function download(context: BaseContext, config: DownloadConfig): Promise\<DownloadTask>;
3. function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback\<UploadTask>): void;
4. function upload(context: BaseContext, config: UploadConfig): Promise\<UploadTask>;
**Change Impact**
The application developed based on an earlier version in the stage model needs to be adapted to the new APIs. Otherwise, the original service logic will be affected.
**Key API/Component Changes**
| Module | Class | Method/Attribute/Enum/Constant | Change Type|
|--------------|--------------|-------------------------------------------------------------------------------------------------------------------|------|
| ohos.request | request | function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback\<DownloadTask>): void; | Deleted |
| ohos.request | request | function download(context: BaseContext, config: DownloadConfig): Promise\<DownloadTask>; | Deleted |
| ohos.request | request | function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback\<UploadTask>): void; | Deleted |
| ohos.request | request | function upload(context: BaseContext, config: UploadConfig): Promise\<UploadTask>; | Deleted |
**Adaptation Guide**
Call the new APIs. The following uses **downloadFile** as an example to show how it is called in the new version:
```ts
try {
request.downloadFile(globalThis.abilityContext, { url: 'https://xxxx/xxxxx.hap',
filePath: 'xxx/xxxxx.hap'}, (err, data) => {
if (err) {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
return;
}
});
} catch (err) {
console.log("downloadFile callback fail." + "errCode:" + err.code + ",errMessage:" + err.message);
}
```
# Web Subsystem Changelog
Compared with earlier versions, OpenHarmony 3.2.10.7 has the following API changes in its web subsystem:
## cl.web.1 HitTestTypeV9 Name Change
Renamed the enum class **HitTestTypeV9** **WebHitTestType** to meet the naming conventions.
**Change Impact**
The enum class **HitTestTypeV9** and APIs that use **HitTestTypeV9** as a parameter or return value cannot be used in OpenHarmony 3.2.10.7 and later versions.
**Key API/Component Changes**
- Involved APIs:
enum HitTestTypeV9
- Before change:
```ts
enum HitTestTypeV9
```
- After change:
```ts
enum WebHitTestType
```
**Adaptation Guide**
Replace **HitTestTypeV9** with **WebHitTestType**.
## cl.web.2 HeaderV9 Name Change
Renamed the struct **HeaderV9** **WebHeader** to meet the naming conventions.
**Change Impact**
The struct **HeaderV9** and APIs that use **HeaderV9** as a parameter or return value cannot be used in OpenHarmony 3.2.10.7 and later versions.
**Key API/Component Changes**
- Involved APIs:
interface HeaderV9
- Before change:
```ts
interface HeaderV9
```
- After change:
```ts
interface WebHeader
```
**Adaptation Guide**
Replace **HeaderV9** with **WebHeader**.
## cl.web.3 Member Change of HitTestValue
Rename the member variable **HitTestTypeV9** in the **HitTestValue** struct **WebHitTestType** to meet the naming conventions.
**Change Impact**
The struct **HitTestValue** and APIs that use **HitTestValue** as a parameter or return value cannot be used in OpenHarmony 3.2.10.7 and later versions.
**Key API/Component Changes**
- Involved APIs:
interface HitTestValue
- Before change:
```ts
interface HitTestValue {
/**
* Get the hit test type.
*
* @since 9
*/
type: HitTestTypeV9;
/**
* Get the hit test extra data.
*
* @since 9
*/
extra: string;
}
```
- After change:
```ts
interface HitTestValue {
/**
* Get the hit test type.
*
* @since 9
*/
type: WebHitTestType;
/**
* Get the hit test extra data.
*
* @since 9
*/
extra: string;
}
```
**Adaptation Guide**
Replace **HitTestTypeV9** with **WebHitTestType**.
## cl.web.4 Parameter Type Change of loadUrl
Changed the type of the **headers** parameter in **loadUrl** to **WebHeader** to meet the naming conventions.
**Change Impact**
The **loadUrl** API that uses the **headers** parameter cannot be used in OpenHarmony 3.2.10.7 and later versions.
**Key API/Component Changes**
- Involved APIs:
loadUrl(url: string | Resource, headers?: Array\<HeaderV9>): void
- Before change:
```ts
loadUrl(url: string | Resource, headers?: Array<HeaderV9>): void
```
- After change:
```ts
loadUrl(url: string | Resource, headers?: Array<WebHeader>): void
```
**Adaptation Guide**
Change the type of the **headers** parameter in **loadUrl** from **HeaderV9** to **WebHeader**.
## cl.web.5 Return Value Type Change of getHitTest
Changed the return value type of the **getHitTest** API to **WebHitTest** to meet the naming conventions.
**Change Impact**
The **getHitTest** API cannot be used in OpenHarmony 3.2.10.7 and later versions.
**Key API/Component Changes**
- Involved APIs:
getHitTest(): HitTestTypeV9
- Before change:
```ts
getHitTest(): HitTestTypeV9
```
- After change:
```ts
getHitTest(): WebHitTestType
```
**Adaptation Guide**
Change the return value type of the **getHitTest** API from **HitTestTypeV9** to **WebHitTestType**.
## cl.web.6 Moving of the WebMessagePort Class
Moved the **WebMessagePort** class to **@ohos.web.webview.d.ts** and added error throwing.
**Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed. In addition, be mindful of the error codes now that the APIs in the class support error code processing.
**Key API/Component Changes**
- Involved APIs:
postMessageEvent(message: WebMessageEvent): void;
onMessageEvent(callback: (result: string) => void): void;
- Before change:
```ts
postMessageEvent(message: WebMessageEvent): void;
onMessageEvent(callback: (result: string) => void): void;
```
- After change:
```ts
postMessageEvent(message: WebMessage): void;
onMessageEvent(callback: (result: WebMessage) => void): void;
```
**Adaptation Guide**
Instead of importing APIs from the original **WebMessagePort** class, import APIs from **@ohos.web.webview** as follows:
```ts
import web_webview from '@ohos.web.webview';
```
## cl.web.7 Moving of the HitTestValue Class
Moved the **HitTestValue** class to **@ohos.web.webview.d.ts**; changed **HitTestValue** from a class to an API; changed the **getType** and **getExtra** from APIs to attributes.
**Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed.
**Key API/Component Changes**
- Involved APIs:
getType(): HitTestType;
getExtra(): string;
- Before change:
```ts
getType(): HitTestType;
getExtra(): string;
```
- After change:
```ts
type: WebHitTestType;
extra: string;
```
**Adaptation Guide**
Instead of importing APIs from the original **HitTestValue** class, import APIs from **@ohos.web.webview** as follows:
```ts
import web_webview from '@ohos.web.webview';
```
## cl.web.8 Moving of API Version 9 APIs Under WebCookie
Moved APIs of API version 9 in the **WebCookie** class to **web.webview.webview.WebCookieManager**
and added error throwing.
**Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed. In addition, be mindful of the error codes now that the APIs in the class support error code processing.
The APIs in the class are static.
**Key API/Component Changes**
- Involved APIs:
isCookieAllowed(): boolean;
isThirdPartyCookieAllowed(): boolean;
putAcceptCookieEnabled(accept: boolean): void;
putAcceptThirdPartyCookieEnabled(accept: boolean): void;
setCookie(url: string, value: string): boolean;
saveCookieSync(): boolean;
getCookie(url: string): string;
existCookie(): boolean;
deleteEntireCookie(): void;
deleteSessionCookie(): void;
- Before change:
```ts
isCookieAllowed(): boolean;
isThirdPartyCookieAllowed(): boolean;
putAcceptCookieEnabled(accept: boolean): void;
putAcceptThirdPartyCookieEnabled(accept: boolean): void;
setCookie(url: string, value: string): boolean;
saveCookieSync(): boolean;
getCookie(url: string): string;
existCookie(): boolean;
deleteEntireCookie(): void;
deleteSessionCookie(): void;
```
- After change:
```ts
static isCookieAllowed(): boolean;
static isThirdPartyCookieAllowed(): boolean;
static putAcceptCookieEnabled(accept: boolean): void;
static putAcceptThirdPartyCookieEnabled(accept: boolean): void;
static setCookie(url: string, value: string): void;
static saveCookieAsync(): Promise<void>;
static saveCookieAsync(callback: AsyncCallback<void>): void;
static getCookie(url: string): string;
static existCookie(): boolean;
static deleteEntireCookie(): void;
static deleteSessionCookie(): void;
```
**Adaptation Guide**
Instead of importing APIs from the original **WebCookie** class, import APIs from **@ohos.web.webview** as follows:
```ts
import web_webview from '@ohos.web.webview';
```
## cl.web.9 Moving of API Version 9 APIs Under WebController
Moved APIs of API version 9 in the **WebController** class to **web.webview.webview.WebviewController** and added error throwing.
**Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed. In addition, be mindful of the error codes now that the APIs in the class support error code processing.
The **getDefaultUserAgent** API is renamed **getUserAgent**.
**Key API/Component Changes**
- Involved APIs:
zoomIn(): boolean;
zoomOut(): boolean;
createWebMessagePorts(): Array\<WebMessagePort>;
postMessage(options: { message: WebMessageEvent, uri: string}): void;
getHitTestValue(): HitTestValue;
getWebId(): number;
getDefaultUserAgent(): string;
getTitle(): string;
getPageHeight(): number;
backOrForward(step: number): void;
searchAllAsync(searchString: string): void;
clearMatches(): void;
searchNext(forward: boolean): void;
clearSslCache(): void;
clearClientAuthenticationCache(): void;
getUrl(): string;
- Before change:
```ts
zoomIn(): boolean;
zoomOut(): boolean;
createWebMessagePorts(): Array<WebMessagePort>;
postMessage(options: { message: WebMessageEvent, uri: string}): void;
getHitTestValue(): HitTestValue;
getWebId(): number;
getDefaultUserAgent(): string;
getTitle(): string;
getPageHeight(): number;
backOrForward(step: number): void;
searchAllAsync(searchString: string): void;
clearMatches(): void;
searchNext(forward: boolean): void;
clearSslCache(): void;
clearClientAuthenticationCache(): void;
getUrl(): string;
```
- After change:
```ts
zoomIn(): void;
zoomOut(): void;
createWebMessagePorts(): Array<WebMessagePort>;
postMessage(name: string, ports: Array<WebMessagePort>, uri: string): void;
getHitTestValue(): HitTestValue;
getWebId(): number;
getUserAgent(): string;
getTitle(): string;
getPageHeight(): number;
backOrForward(step: number): void;
searchAllAsync(searchString: string): void;
clearMatches(): void;
searchNext(forward: boolean): void;
clearSslCache(): void;
clearClientAuthenticationCache(): void;
getUrl(): string;
```
**Adaptation Guide**
Instead of importing APIs from the original **WebController** class, import APIs from **@ohos.web.webview** as follows:
```ts
import web_webview from '@ohos.web.webview';
```
## cl.web.10 Moving of the WebAsyncController Class
Moved the APIs in the **WebAsyncController** class to the **web.webview.webview.WebviewController** class and added error throwing.
**Change Impact**
If your application is developed based on earlier versions, pay attention to error code processing.
**Key API/Component Changes**
- Involved APIs:
storeWebArchive(baseName: string, autoName: boolean): Promise\<string>;
storeWebArchive(baseName: string, autoName: boolean, callback : AsyncCallback\<string>): void;
- Before change:
```ts
storeWebArchive(baseName: string, autoName: boolean): Promise<string>;
storeWebArchive(baseName: string, autoName: boolean, callback : AsyncCallback<string>): void;
```
- After change:
```ts
storeWebArchive(baseName: string, autoName: boolean): Promise<string>;
storeWebArchive(baseName: string, autoName: boolean, callback : AsyncCallback<string>): void;
```
**Adaptation Guide**
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() {
Button('saveWebArchive')
.onClick(() => {
try {
this.controller.storeWebArchive("/data/storage/el2/base/", true, (error, filename) => {
if (error) {
console.info(`save web archive error: ` + JSON.stringify(error))
return;
}
if (filename != null) {
console.info(`save web archive success: ${filename}`)
}
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
# Web Subsystem Changelog
Compared with earlier versions, OpenHarmony 4.0.3.2 has the following API changes in its web subsystem:
## cl.web.1 HitTestTypeV9 Name Change
Renamed the enum class **HitTestTypeV9** **WebHitTestType** to meet the naming conventions.
**Change Impact**
The enum class **HitTestTypeV9** and APIs that use **HitTestTypeV9** as a parameter or return value cannot be used in OpenHarmony 4.0.3.2 and later versions.
**Key API/Component Changes**
- Involved APIs:
enum HitTestTypeV9
- Before change:
```ts
enum HitTestTypeV9
```
- After change:
```ts
enum WebHitTestType
```
**Adaptation Guide**
Replace **HitTestTypeV9** with **WebHitTestType**.
## cl.web.2 HeaderV9 Name Change
Renamed the struct **HeaderV9** **WebHeader** to meet the naming conventions.
**Change Impact**
The struct **HeaderV9** and APIs that use **HeaderV9** as a parameter or return value cannot be used in OpenHarmony 4.0.3.2 and later versions.
**Key API/Component Changes**
- Involved APIs:
interface HeaderV9
- Before change:
```ts
interface HeaderV9
```
- After change:
```ts
interface WebHeader
```
**Adaptation Guide**
Replace **HeaderV9** with **WebHeader**.
## cl.web.3 Member Change of HitTestValue
Rename the member variable **HitTestTypeV9** in the **HitTestValue** struct **WebHitTestType** to meet the naming conventions.
**Change Impact**
The struct **HitTestValue** and APIs that use **HitTestValue** as a parameter or return value cannot be used in OpenHarmony 4.0.3.2 and later versions.
**Key API/Component Changes**
- Involved APIs:
interface HitTestValue
- Before change:
```ts
interface HitTestValue {
/**
* Get the hit test type.
*
* @since 9
*/
type: HitTestTypeV9;
/**
* Get the hit test extra data.
*
* @since 9
*/
extra: string;
}
```
- After change:
```ts
interface HitTestValue {
/**
* Get the hit test type.
*
* @since 9
*/
type: WebHitTestType;
/**
* Get the hit test extra data.
*
* @since 9
*/
extra: string;
}
```
**Adaptation Guide**
Replace **HitTestTypeV9** with **WebHitTestType**.
## cl.web.4 Parameter Type Change of loadUrl
Changed the type of the **headers** parameter in **loadUrl** to **WebHeader** to meet the naming conventions.
**Change Impact**
The **loadUrl** API that uses the **headers** parameter cannot be used in OpenHarmony 4.0.3.2 and later versions.
**Key API/Component Changes**
- Involved APIs:
loadUrl(url: string | Resource, headers?: Array\<HeaderV9>): void
- Before change:
```ts
loadUrl(url: string | Resource, headers?: Array<HeaderV9>): void
```
- After change:
```ts
loadUrl(url: string | Resource, headers?: Array<WebHeader>): void
```
**Adaptation Guide**
Change the type of the **headers** parameter in **loadUrl** from **HeaderV9** to **WebHeader**.
## cl.web.5 Return Value Type Change of getHitTest
Changed the return value type of the **getHitTest** API to **WebHitTest** to meet the naming conventions.
**Change Impact**
The **getHitTest** API cannot be used in OpenHarmony 4.0.3.2 and later versions.
**Key API/Component Changes**
- Involved APIs:
getHitTest(): HitTestTypeV9
- Before change:
```ts
getHitTest(): HitTestTypeV9
```
- After change:
```ts
getHitTest(): WebHitTestType
```
**Adaptation Guide**
Change the return value type of the **getHitTest** API from **HitTestTypeV9** to **WebHitTestType**.
## cl.web.6 Moving of the WebMessagePort Class
Moved the **WebMessagePort** class to **@ohos.web.webview.d.ts** and added error throwing.
**Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed. In addition, be mindful of the error codes now that the APIs in the class support error code processing.
**Key API/Component Changes**
- Involved APIs:
postMessageEvent(message: WebMessageEvent): void;
onMessageEvent(callback: (result: string) => void): void;
- Before change:
```ts
postMessageEvent(message: WebMessageEvent): void;
onMessageEvent(callback: (result: string) => void): void;
```
- After change:
```ts
postMessageEvent(message: WebMessage): void;
onMessageEvent(callback: (result: WebMessage) => void): void;
```
**Adaptation Guide**
Instead of importing APIs from the original **WebMessagePort** class, import APIs from **@ohos.web.webview** as follows:
```ts
import web_webview from '@ohos.web.webview';
```
## cl.web.7 Moving of the HitTestValue Class
Moved the **HitTestValue** class to **@ohos.web.webview.d.ts**; changed **HitTestValue** from a class to an API; changed the **getType** and **getExtra** from APIs to attributes.
**Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed.
**Key API/Component Changes**
- Involved APIs:
getType(): HitTestType;
getExtra(): string;
- Before change:
```ts
getType(): HitTestType;
getExtra(): string;
```
- After change:
```ts
type: WebHitTestType;
extra: string;
```
**Adaptation Guide**
Instead of importing APIs from the original **HitTestValue** class, import APIs from **@ohos.web.webview** as follows:
```ts
import web_webview from '@ohos.web.webview';
```
## cl.web.8 Moving of API Version 9 APIs Under WebCookie
Moved APIs of API version 9 in the **WebCookie** class to **web.webview.webview.WebCookieManager**
and added error throwing.
**Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed. In addition, be mindful of the error codes now that the APIs in the class support error code processing.
The APIs in the class are static.
**Key API/Component Changes**
- Involved APIs:
isCookieAllowed(): boolean;
isThirdPartyCookieAllowed(): boolean;
putAcceptCookieEnabled(accept: boolean): void;
putAcceptThirdPartyCookieEnabled(accept: boolean): void;
setCookie(url: string, value: string): boolean;
saveCookieSync(): boolean;
getCookie(url: string): string;
existCookie(): boolean;
deleteEntireCookie(): void;
deleteSessionCookie(): void;
- Before change:
```ts
isCookieAllowed(): boolean;
isThirdPartyCookieAllowed(): boolean;
putAcceptCookieEnabled(accept: boolean): void;
putAcceptThirdPartyCookieEnabled(accept: boolean): void;
setCookie(url: string, value: string): boolean;
saveCookieSync(): boolean;
getCookie(url: string): string;
existCookie(): boolean;
deleteEntireCookie(): void;
deleteSessionCookie(): void;
```
- After change:
```ts
static isCookieAllowed(): boolean;
static isThirdPartyCookieAllowed(): boolean;
static putAcceptCookieEnabled(accept: boolean): void;
static putAcceptThirdPartyCookieEnabled(accept: boolean): void;
static setCookie(url: string, value: string): void;
static saveCookieAsync(): Promise<void>;
static saveCookieAsync(callback: AsyncCallback<void>): void;
static getCookie(url: string): string;
static existCookie(): boolean;
static deleteEntireCookie(): void;
static deleteSessionCookie(): void;
```
**Adaptation Guide**
Instead of importing APIs from the original **WebCookie** class, import APIs from **@ohos.web.webview** as follows:
```ts
import web_webview from '@ohos.web.webview';
```
## cl.web.9 Moving of API Version 9 APIs Under WebController
Moved APIs of API version 9 in the **WebController** class to **web.webview.webview.WebviewController** and added error throwing.
**Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed. In addition, be mindful of the error codes now that the APIs in the class support error code processing.
The **getDefaultUserAgent** API is renamed **getUserAgent**.
**Key API/Component Changes**
- Involved APIs:
zoomIn(): boolean;
zoomOut(): boolean;
createWebMessagePorts(): Array\<WebMessagePort>;
postMessage(options: { message: WebMessageEvent, uri: string}): void;
getHitTestValue(): HitTestValue;
getWebId(): number;
getDefaultUserAgent(): string;
getTitle(): string;
getPageHeight(): number;
backOrForward(step: number): void;
searchAllAsync(searchString: string): void;
clearMatches(): void;
searchNext(forward: boolean): void;
clearSslCache(): void;
clearClientAuthenticationCache(): void;
getUrl(): string;
- Before change:
```ts
zoomIn(): boolean;
zoomOut(): boolean;
createWebMessagePorts(): Array<WebMessagePort>;
postMessage(options: { message: WebMessageEvent, uri: string}): void;
getHitTestValue(): HitTestValue;
getWebId(): number;
getDefaultUserAgent(): string;
getTitle(): string;
getPageHeight(): number;
backOrForward(step: number): void;
searchAllAsync(searchString: string): void;
clearMatches(): void;
searchNext(forward: boolean): void;
clearSslCache(): void;
clearClientAuthenticationCache(): void;
getUrl(): string;
```
- After change:
```ts
zoomIn(): void;
zoomOut(): void;
createWebMessagePorts(): Array<WebMessagePort>;
postMessage(name: string, ports: Array<WebMessagePort>, uri: string): void;
getHitTestValue(): HitTestValue;
getWebId(): number;
getUserAgent(): string;
getTitle(): string;
getPageHeight(): number;
backOrForward(step: number): void;
searchAllAsync(searchString: string): void;
clearMatches(): void;
searchNext(forward: boolean): void;
clearSslCache(): void;
clearClientAuthenticationCache(): void;
getUrl(): string;
```
**Adaptation Guide**
Instead of importing APIs from the original **WebController** class, import APIs from **@ohos.web.webview** as follows:
```ts
import web_webview from '@ohos.web.webview';
```
## cl.web.10 Moving of the WebAsyncController Class
Moved the APIs in the **WebAsyncController** class to the **web.webview.webview.WebviewController** class and added error throwing.
**Change Impact**
If your application is developed based on earlier versions, pay attention to error code processing.
**Key API/Component Changes**
- Involved APIs:
storeWebArchive(baseName: string, autoName: boolean): Promise\<string>;
storeWebArchive(baseName: string, autoName: boolean, callback : AsyncCallback\<string>): void;
- Before change:
```ts
storeWebArchive(baseName: string, autoName: boolean): Promise<string>;
storeWebArchive(baseName: string, autoName: boolean, callback : AsyncCallback<string>): void;
```
- After change:
```ts
storeWebArchive(baseName: string, autoName: boolean): Promise<string>;
storeWebArchive(baseName: string, autoName: boolean, callback : AsyncCallback<string>): void;
```
**Adaptation Guide**
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() {
Button('saveWebArchive')
.onClick(() => {
try {
this.controller.storeWebArchive("/data/storage/el2/base/", true, (error, filename) => {
if (error) {
console.info(`save web archive error: ` + JSON.stringify(error))
return;
}
if (filename != null) {
console.info(`save web archive success: ${filename}`)
}
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
...@@ -19,7 +19,7 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis ...@@ -19,7 +19,7 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis
> 如果服务已创建,再次启动该InputMethodExtensionAbility不会触发onCreate()回调。 > 如果服务已创建,再次启动该InputMethodExtensionAbility不会触发onCreate()回调。
- **onDestroy** - **onDestroy**
当不再使用服务且准备将其销毁该实例时,触发该回调。开发者可以在该回调中清理资源,如注销监听等。 当不再使用服务且准备将该实例销毁时,触发该回调。开发者可以在该回调中清理资源,如注销监听等。
## 开发步骤 ## 开发步骤
...@@ -28,19 +28,22 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis ...@@ -28,19 +28,22 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis
在工程Module对应的ets目录下,右键选择“New &gt; Extention Ability > InputMethod”,即可创建出InputMethodExtensionAbility的最小化模板。 在工程Module对应的ets目录下,右键选择“New &gt; Extention Ability > InputMethod”,即可创建出InputMethodExtensionAbility的最小化模板。
> **说明:**
> 在编译输入法应用时,要使用system_core级别的签名,否则无法拉起输入法键盘。
> [签名指导](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465)
最小化模板为一个最基本的输入法应用,包含软键盘拉起以及输入删除功能。后续开发者可在此基础上添加功能,如隐藏键盘等,实现自己的输入法应用。 最小化模板为一个最基本的输入法应用,包含软键盘拉起以及输入删除功能。后续开发者可在此基础上添加功能,如隐藏键盘等,实现自己的输入法应用。
最小化模板主要包含四个文件,分别为KeyboardController.ts、InputMethodService.ts、Index.ets以及KeyboardKeyData.ts。目录如下: 最小化模板主要包含四个文件,分别为KeyboardController.ts、InputMethodService.ts、Index.ets以及KeyboardKeyData.ts。目录如下:
``` ```
/src/main/ /src/main/
├── ets/InputMethodExtAbility ├── ets/inputmethodextability
│ └──model/KeyboardController.ts # 显示键盘 │ └──model/KeyboardController.ts # 显示键盘
│ └──InputMethodService.ts # 自定义类继承InputMethodExtensionAbility并加上需要的生命周期回调 │ └──InputMethodService.ts # 自定义类继承InputMethodExtensionAbility并加上需要的生命周期回调
│ └──pages │ └──pages
│ └──InputMethodExtAbility │ └── Index.ets # 绘制键盘,添加输入删除功能
│ └── Index.ets # 绘制键盘,添加输入删除功能 │ └── KeyboardKeyData.ts # 键盘属性定义
│ └── KeyboardKeyData.ts # 键盘属性定义
├── resources/base/profile/main_pages.json ├── resources/base/profile/main_pages.json
``` ```
...@@ -64,7 +67,7 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis ...@@ -64,7 +67,7 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis
onDestroy() { onDestroy() {
console.log("onDestroy."); console.log("onDestroy.");
this.context.destroy() this.context.destroy();
} }
} }
``` ```
...@@ -72,16 +75,16 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis ...@@ -72,16 +75,16 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis
2. KeyboardController.ts文件。 2. KeyboardController.ts文件。
```ts ```ts
import inputMethodEngine from '@ohos.inputMethodEngine' import inputMethodEngine from '@ohos.inputMethodEngine';
import display from '@ohos.display' import display from '@ohos.display';
import windowManager from '@ohos.window' import windowManager from '@ohos.window';
// 调用输入法框架的getInputMethodAbility方法获取实例,并由此实例调用输入法框架功能接口 // 调用输入法框架的getInputMethodAbility方法获取实例,并由此实例调用输入法框架功能接口
globalThis.inputAbility = inputMethodEngine.getInputMethodAbility(); globalThis.inputAbility = inputMethodEngine.getInputMethodAbility();
export class KeyboardController { export class KeyboardController {
mContext // 保存InputMethodExtensionAbility中的context属性 mContext; // 保存InputMethodExtensionAbility中的context属性
WINDOW_TYPE_INPUT_METHOD_FLOAT = 2105 // 定义窗口类型,2105代表输入法窗口类型,用于创建输入法应用窗口 WINDOW_TYPE_INPUT_METHOD_FLOAT = 2105; // 定义窗口类型,2105代表输入法窗口类型,用于创建输入法应用窗口
windowName = 'inputApp'; windowName = 'inputApp';
private windowHeight: number = 0; private windowHeight: number = 0;
private windowWidth: number = 0; private windowWidth: number = 0;
...@@ -101,32 +104,31 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis ...@@ -101,32 +104,31 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis
public onDestroy(): void // 应用生命周期销毁 public onDestroy(): void // 应用生命周期销毁
{ {
this.unRegisterListener(); // 注销事件监听 this.unRegisterListener(); // 注销事件监听
var win = windowManager.findWindow(this.windowName) let win = windowManager.findWindow(this.windowName);
win.destroyWindow() // 销毁窗口 win.destroyWindow(); // 销毁窗口
this.mContext.terminateSelf(); // 销毁InputMethodExtensionAbility服务 this.mContext.terminateSelf(); // 销毁InputMethodExtensionAbility服务
} }
private initWindow(): void // 初始化窗口 private initWindow(): void // 初始化窗口
{ {
display.getDefaultDisplay().then(dis => { let dis = display.getDefaultDisplaySync();
var dWidth = dis.width; let dWidth = dis.width;
var dHeight = dis.height; let dHeight = dis.height;
var keyHeightRate = 0.47; let keyHeightRate = 0.47;
var keyHeight = dHeight * keyHeightRate; let keyHeight = dHeight * keyHeightRate;
this.windowWidth = dWidth; this.windowWidth = dWidth;
this.windowHeight = keyHeight; this.windowHeight = keyHeight;
this.nonBarPosition = dHeight - keyHeight this.nonBarPosition = dHeight - keyHeight;
var config = { let config = {
name: this.windowName, name: this.windowName,
windowType: this.WINDOW_TYPE_INPUT_METHOD_FLOAT, windowType: this.WINDOW_TYPE_INPUT_METHOD_FLOAT,
ctx: this.mContext ctx: this.mContext
} }
windowManager.createWindow(config).then((win) => { // 根据窗口类型创建窗口 windowManager.createWindow(config).then((win) => { // 根据窗口类型创建窗口
win.resize(dWidth, keyHeight).then(() => { win.resize(dWidth, keyHeight).then(() => {
win.moveWindowTo(0, this.nonBarPosition).then(() => { win.moveWindowTo(0, this.nonBarPosition).then(() => {
win.setUIContent('pages/InputMethodExtAbility/Index').then(() => { win.setUIContent('pages/InputMethodExtAbility/Index').then(() => {
});
}); });
}); });
}); });
...@@ -153,7 +155,7 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis ...@@ -153,7 +155,7 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis
globalThis.keyboardController = kbController; globalThis.keyboardController = kbController;
}) })
globalThis.inputAbility.on('inputStop', (imeId) => { globalThis.inputAbility.on('inputStop', (imeId) => {
if (imeId == "com.example.kikainput/InputDemoService") { if (imeId == "包名/Ability名") {
this.onDestroy(); this.onDestroy();
} }
}); });
...@@ -162,12 +164,12 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis ...@@ -162,12 +164,12 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis
private unRegisterListener(): void private unRegisterListener(): void
{ {
globalThis.inputAbility.off('inputStart'); globalThis.inputAbility.off('inputStart');
globalThis.inputAbility.off('inputStop'); globalThis.inputAbility.off('inputStop', () => {});
globalThis.inputAbility.off('keyboardShow'); globalThis.inputAbility.off('keyboardShow');
} }
private showHighWindow() { private showHighWindow() {
var win = windowManager.findWindow(this.windowName) let win = windowManager.findWindow(this.windowName)
win.resize(this.windowWidth, this.windowHeight).then(() => { win.resize(this.windowWidth, this.windowHeight).then(() => {
win.moveWindowTo(0, this.nonBarPosition).then(() => { win.moveWindowTo(0, this.nonBarPosition).then(() => {
win.showWindow().then(() => { win.showWindow().then(() => {
......
...@@ -119,7 +119,7 @@ DataShare即数据共享模块,提供了向其他应用共享以及管理其 ...@@ -119,7 +119,7 @@ DataShare即数据共享模块,提供了向其他应用共享以及管理其
rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) { rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) {
console.log('DataShareExtAbility onCreate, executeSql done err:' + JSON.stringify(err)); console.log('DataShareExtAbility onCreate, executeSql done err:' + JSON.stringify(err));
}); });
if (callbakc) { if (callback) {
callback(); callback();
} }
}); });
......
# full-SDK编译指南
**full-SDK**是提供OpenHarmony全量接口的SDK,包含了系统应用所需要的高权限API,用于厂商开发应用。
从OpenHarmony3.2Beta5版本开始,不在随版本提供**full-SDK**。如有需要,可通过全量源码自行编译。
## 编译full-SDK
**前提条件**
1. 需注册码云SSH公钥,具体请参考 http://gitee.com/help/articles/4191
2. 配置服务器环境,具体请参考[搭建开发环境](../../device-dev/quick-start/quickstart-ide-env-ubuntu.md)
**下载和编译命令**
1. 初始化manifest:repo init -u https://gitee.com/openharmony/manifest.git -b $manifest_branch --no-repo-verify --repo-url=https://gitee.com/oschina/repo --no-clone-bundle
2. 根据上面下载的manifest仓进行下载代码:repo sync -c -d --force-sync
3. 预编译:yes y | apt install libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev && rm -rf prebuilts/clang/ohos/darwin-x86_64/clang-480513 && rm -rf prebuilts/clang/ohos/windows-x86_64/clang-480513 && rm -rf prebuilts/clang/ohos/linux-x86_64/clang-480513 && bash build/prebuilts_download.sh -ndk && apt-get update -qqy && apt-get install doxygen -y --force-yes
4. 编译:./build.sh --product-name ohos-sdk
编译成功后导出即可
## 替换SDK
full-SDK编译完成后需要在DevEcoStudio替换使用,具体请参考[full-SDK替换指南](../../application-dev/quick-start/full-sdk-switch-guide.md)
...@@ -117,6 +117,7 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback: ...@@ -117,6 +117,7 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback:
| 17700016 | Failed to install the HAP because of insufficient system disk space. | | 17700016 | Failed to install the HAP because of insufficient system disk space. |
| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | | 17700017 | Failed to install the HAP since the version of the HAP to install is too early. |
| 17700018 | Failed to install because the dependent module does not exist. | | 17700018 | Failed to install because the dependent module does not exist. |
| 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. |
**示例:** **示例:**
......
...@@ -473,9 +473,9 @@ console.log('current path = ' + page.path); ...@@ -473,9 +473,9 @@ console.log('current path = ' + page.path);
| name | string | 否 | 表示当前页面的名称,即对应文件名。 | | name | string | 否 | 表示当前页面的名称,即对应文件名。 |
| path | string | 是 | 表示当前页面的路径。 | | path | string | 是 | 表示当前页面的路径。 |
## router.enableBackPageAlert<sup>9+</sup> ## router.showAlertBeforeBackPage<sup>9+</sup>
enableBackPageAlert(options: EnableAlertOptions): void showAlertBeforeBackPage(options: EnableAlertOptions): void
开启页面返回询问对话框。 开启页面返回询问对话框。
...@@ -499,11 +499,11 @@ enableBackPageAlert(options: EnableAlertOptions): void ...@@ -499,11 +499,11 @@ enableBackPageAlert(options: EnableAlertOptions): void
```js ```js
try { try {
router.enableBackPageAlert({ router.showAlertBeforeBackPage({
message: 'Message Info' message: 'Message Info'
}); });
} catch(error) { } catch(error) {
console.error(`enableBackPageAlert failed, code is ${error.code}, message is ${error.message}`); console.error(`showAlertBeforeBackPage failed, code is ${error.code}, message is ${error.message}`);
} }
``` ```
## EnableAlertOptions ## EnableAlertOptions
...@@ -516,9 +516,9 @@ try { ...@@ -516,9 +516,9 @@ try {
| ------- | ------ | ---- | -------- | | ------- | ------ | ---- | -------- |
| message | string | 是 | 询问对话框内容。 | | message | string | 是 | 询问对话框内容。 |
## router.disableAlertBeforeBackPage ## router.hideAlertBeforeBackPage<sup>9+</sup>
disableAlertBeforeBackPage(): void hideAlertBeforeBackPage(): void
禁用页面返回询问对话框。 禁用页面返回询问对话框。
...@@ -527,7 +527,7 @@ disableAlertBeforeBackPage(): void ...@@ -527,7 +527,7 @@ disableAlertBeforeBackPage(): void
**示例:** **示例:**
```js ```js
router.disableAlertBeforeBackPage(); router.hideAlertBeforeBackPage();
``` ```
## router.getParams ## router.getParams
...@@ -748,7 +748,7 @@ enableAlertBeforeBackPage(options: EnableAlertOptions): void ...@@ -748,7 +748,7 @@ enableAlertBeforeBackPage(options: EnableAlertOptions): void
开启页面返回询问对话框。 开启页面返回询问对话框。
从API version9开始不再维护,建议使用[enableBackPageAlert<sup>9+</sup>](#routerenablebackpagealert9) 从API version9开始不再维护,建议使用[showAlertBeforeBackPage<sup>9+</sup>](#routershowalertbeforebackpage9)
**系统能力:** SystemCapability.ArkUI.ArkUI.Full **系统能力:** SystemCapability.ArkUI.ArkUI.Full
...@@ -764,4 +764,20 @@ enableAlertBeforeBackPage(options: EnableAlertOptions): void ...@@ -764,4 +764,20 @@ enableAlertBeforeBackPage(options: EnableAlertOptions): void
router.enableAlertBeforeBackPage({ router.enableAlertBeforeBackPage({
message: 'Message Info' message: 'Message Info'
}); });
``` ```
\ No newline at end of file
## router.disableAlertBeforeBackPage<sup>(deprecated)</sup>
disableAlertBeforeBackPage(): void
禁用页面返回询问对话框。
从API version9开始不再维护,建议使用[hideAlertBeforeBackPage<sup>9+</sup>](#routerhidealertbeforebackpage9)
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**示例:**
```js
router.disableAlertBeforeBackPage();
```
\ No newline at end of file
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
import web_webview from '@ohos.web.webview'; import web_webview from '@ohos.web.webview';
``` ```
### once ## once
once(type: string, callback: Callback\<void\>): void once(type: string, callback: Callback\<void\>): void
...@@ -43,7 +43,7 @@ import web_webview from '@ohos.web.webview' ...@@ -43,7 +43,7 @@ import web_webview from '@ohos.web.webview'
web_webview.once("webInited", () => { web_webview.once("webInited", () => {
console.log("setCookie") console.log("setCookie")
web_webview.WebCookieManager.setCookie("www.example.com", "a=b") web_webview.WebCookieManager.setCookie("https://www.example.com", "a=b")
}) })
@Entry @Entry
...@@ -379,12 +379,12 @@ struct WebComponent { ...@@ -379,12 +379,12 @@ struct WebComponent {
} }
}) })
Web({ src: 'www.example.com', controller: this.controller }) Web({ src: 'www.example.com', controller: this.controller })
.webDebuggingAccess(true)
} }
} }
} }
``` ```
加载本地网页
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview' import web_webview from '@ohos.web.webview'
...@@ -399,7 +399,7 @@ struct WebComponent { ...@@ -399,7 +399,7 @@ struct WebComponent {
Button('loadUrl') Button('loadUrl')
.onClick(() => { .onClick(() => {
try { try {
//需要加载的URL是Resource类型 //通过$rawfile加载本地资源文件
this.controller.loadUrl($rawfile('xxx.html')); this.controller.loadUrl($rawfile('xxx.html'));
} catch (error) { } catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
...@@ -411,6 +411,32 @@ struct WebComponent { ...@@ -411,6 +411,32 @@ struct WebComponent {
} }
``` ```
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('loadUrl')
.onClick(() => {
try {
//通过resource协议加载本地资源文件
this.controller.loadUrl("resource://rawfile/xxx.html");
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
```html ```html
<!-- xxx.html --> <!-- xxx.html -->
<!DOCTYPE html> <!DOCTYPE html>
...@@ -479,7 +505,34 @@ struct WebComponent { ...@@ -479,7 +505,34 @@ struct WebComponent {
} }
``` ```
### accessforward 加载本地资源
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
updataContent: string = '<body><div><image src=resource://rawfile/xxx.png alt="image -- end" width="500" height="250"></image></div></body>'
build() {
Column() {
Button('loadData')
.onClick(() => {
try {
this.controller.loadData(this.updataContent, "text/html", "UTF-8", " ", " ");
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### accessForward
accessForward(): boolean accessForward(): boolean
...@@ -1606,7 +1659,7 @@ struct WebComponent { ...@@ -1606,7 +1659,7 @@ struct WebComponent {
.onClick(() => { .onClick(() => {
try { try {
if (this.ports && this.ports[1]) { if (this.ports && this.ports[1]) {
this.ports[1].postMessageEvent("this.sendFromEts"); this.ports[1].postMessageEvent(this.sendFromEts);
} else { } else {
console.error(`ports is null, Please initialize first`); console.error(`ports is null, Please initialize first`);
} }
...@@ -3215,7 +3268,7 @@ struct WebComponent { ...@@ -3215,7 +3268,7 @@ struct WebComponent {
Button('getCookie') Button('getCookie')
.onClick(() => { .onClick(() => {
try { try {
let value = web_webview.WebCookieManager.getCookie('www.example.com'); let value = web_webview.WebCookieManager.getCookie('https://www.example.com');
console.log("value: " + value); console.log("value: " + value);
} catch (error) { } catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
...@@ -3267,7 +3320,7 @@ struct WebComponent { ...@@ -3267,7 +3320,7 @@ struct WebComponent {
Button('setCookie') Button('setCookie')
.onClick(() => { .onClick(() => {
try { try {
web_webview.WebCookieManager.setCookie('www.example.com', 'a=b'); web_webview.WebCookieManager.setCookie('https://www.example.com', 'a=b');
} catch (error) { } catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
} }
...@@ -4135,9 +4188,6 @@ struct WebComponent { ...@@ -4135,9 +4188,6 @@ struct WebComponent {
try { try {
this.username_password = web_webview.WebDataBase.getHttpAuthCredentials(this.host, this.realm); this.username_password = web_webview.WebDataBase.getHttpAuthCredentials(this.host, this.realm);
console.log('num: ' + this.username_password.length); console.log('num: ' + this.username_password.length);
ForEach(this.username_password, (item) => {
console.log('username_password: ' + item);
}, item => item)
} catch (error) { } catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
} }
......
...@@ -40,7 +40,7 @@ RichText(content:string) ...@@ -40,7 +40,7 @@ RichText(content:string)
| \<br/> | 插入一个简单的换行符。 | \<p>这是一个段落\<br/>这是换行段落\</p> | | \<br/> | 插入一个简单的换行符。 | \<p>这是一个段落\<br/>这是换行段落\</p> |
| \<font/> | 规定文本的字体、字体尺寸、字体颜色。 | \<font size="3" face="arial" color="red">这是一段红色字体。\</font> | | \<font/> | 规定文本的字体、字体尺寸、字体颜色。 | \<font size="3" face="arial" color="red">这是一段红色字体。\</font> |
| \<hr/> | 定义HTML页面中的主题变化(比如话题的转移),并显示为一条水平线。 | \<p>这个一个段落\</p>\<hr/>\<p>这是一个段落\</p> | | \<hr/> | 定义HTML页面中的主题变化(比如话题的转移),并显示为一条水平线。 | \<p>这个一个段落\</p>\<hr/>\<p>这是一个段落\</p> |
| \<image>\</image> | 用来定义图片。 | \<image src="file:///data/storage/el1/bundle/entry/resources/rawfile/icon.png">\</image> | | \<image>\</image> | 用来定义图片。 | \<image src="resource://rawfile/icon.png">\</image> |
| \<div>\</div> | 常用于组合块级元素,以便通过CSS来对这些元素进行格式化。 | \<div style='color:#0000FF'>\<h3>这是一个在div元素中的标题。\</h3>\</div> | | \<div>\</div> | 常用于组合块级元素,以便通过CSS来对这些元素进行格式化。 | \<div style='color:#0000FF'>\<h3>这是一个在div元素中的标题。\</h3>\</div> |
| \<i>\</i> | 定义与文本中其余部分不同的部分,并把这部分文本呈现为斜体文本。 | \<i>这是一个斜体\</i> | | \<i>\</i> | 定义与文本中其余部分不同的部分,并把这部分文本呈现为斜体文本。 | \<i>这是一个斜体\</i> |
| \<u>\</u> | 定义与常规文本风格不同的文本,像拼写错误的单词或者汉语中的专有名词,应尽量避免使用\<u>为文本加下划线,用户会把它混淆为一个超链接。 | \<p>\<u>这是带有下划线的段落\</u>\</p> | | \<u>\</u> | 定义与常规文本风格不同的文本,像拼写错误的单词或者汉语中的专有名词,应尽量避免使用\<u>为文本加下划线,用户会把它混淆为一个超链接。 | \<p>\<u>这是带有下划线的段落\</u>\</p> |
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
## 接口 ## 接口
Web(options: { src: ResourceStr, controller: WebController | WebviewController}) Web(options: { src: ResourceStr, controller: WebviewController | WebController})
> **说明:** > **说明:**
> >
...@@ -27,18 +27,20 @@ Web(options: { src: ResourceStr, controller: WebController | WebviewController}) ...@@ -27,18 +27,20 @@ Web(options: { src: ResourceStr, controller: WebController | WebviewController})
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| ---------- | ---------------------------------------- | ---- | ------- | | ---------- | ---------------------------------------- | ---- | ------- |
| src | [ResourceStr](ts-types.md) | 是 | 网页资源地址。 | | src | [ResourceStr](ts-types.md) | 是 | 网页资源地址。如果访问本地资源文件,请使用$rawfile或者resource协议。 |
| controller | [WebController](#webcontroller) \| [WebviewController<sup>9+</sup>](../apis/js-apis-webview.md#webviewcontroller) | 是 | 控制器。 | | controller | [WebviewController<sup>9+</sup>](../apis/js-apis-webview.md#webviewcontroller) \| [WebController](#webcontroller) | 是 | 控制器。从API Version 9开始,WebController不在维护,建议使用WebviewController替代。 |
**示例:** **示例:**
加载在线网页 加载在线网页
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview'
@Entry @Entry
@Component @Component
struct WebComponent { struct WebComponent {
controller: WebController = new WebController() controller: web_webview.WebviewController = new web_webview.WebviewController()
build() { build() {
Column() { Column() {
Web({ src: 'www.example.com', controller: this.controller }) Web({ src: 'www.example.com', controller: this.controller })
...@@ -46,6 +48,8 @@ Web(options: { src: ResourceStr, controller: WebController | WebviewController}) ...@@ -46,6 +48,8 @@ Web(options: { src: ResourceStr, controller: WebController | WebviewController})
} }
} }
``` ```
加载本地网页
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview' import web_webview from '@ohos.web.webview'
...@@ -56,22 +60,25 @@ Web(options: { src: ResourceStr, controller: WebController | WebviewController}) ...@@ -56,22 +60,25 @@ Web(options: { src: ResourceStr, controller: WebController | WebviewController})
controller: web_webview.WebviewController = new web_webview.WebviewController() controller: web_webview.WebviewController = new web_webview.WebviewController()
build() { build() {
Column() { Column() {
Web({ src: 'www.example.com', controller: this.controller }) //通过$rawfile加载本地资源文件
Web({ src: $rawfile("index.html"), controller: this.controller })
} }
} }
} }
``` ```
加载本地网页
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview'
@Entry @Entry
@Component @Component
struct WebComponent { struct WebComponent {
controller: WebController = new WebController() controller: web_webview.WebviewController = new web_webview.WebviewController()
build() { build() {
Column() { Column() {
Web({ src: $rawfile("index.html"), controller: this.controller }) //通过resource协议加载本地资源文件
Web({ src: "resource://rawfile/index.html"), controller: this.controller })
} }
} }
} }
...@@ -191,7 +198,7 @@ javaScriptProxy(javaScriptProxy: { object: object, name: string, methodList: Arr ...@@ -191,7 +198,7 @@ javaScriptProxy(javaScriptProxy: { object: object, name: string, methodList: Arr
| object | object | 是 | - | 参与注册的对象。只能声明方法,不能声明属性。 | | object | object | 是 | - | 参与注册的对象。只能声明方法,不能声明属性。 |
| name | string | 是 | - | 注册对象的名称,与window中调用的对象名一致。 | | name | string | 是 | - | 注册对象的名称,与window中调用的对象名一致。 |
| methodList | Array\<string\> | 是 | - | 参与注册的应用侧JavaScript对象的方法。 | | methodList | Array\<string\> | 是 | - | 参与注册的应用侧JavaScript对象的方法。 |
| controller | [WebController](#webcontroller) [WebviewController](../apis/js-apis-webview.md#webviewcontroller) | 是 | - | 控制器。 | | controller | [WebController](#webcontroller) \| [WebviewController](../apis/js-apis-webview.md#webviewcontroller) | 是 | - | 控制器。 |
**示例:** **示例:**
...@@ -468,7 +475,7 @@ geolocationAccess(geolocationAccess: boolean) ...@@ -468,7 +475,7 @@ geolocationAccess(geolocationAccess: boolean)
mediaPlayGestureAccess(access: boolean) mediaPlayGestureAccess(access: boolean)
设置有声视频播放是否需要用户手动点击,静音视频播放不受该接口管控。 设置有声视频播放是否需要用户手动点击,静音视频播放不受该接口管控,默认需要
**参数:** **参数:**
...@@ -1156,7 +1163,7 @@ forceDarkAccess(access: boolean) ...@@ -1156,7 +1163,7 @@ forceDarkAccess(access: boolean)
pinchSmooth(isEnabled: boolean) pinchSmooth(isEnabled: boolean)
设置网页是否开启捏合流畅模式。 设置网页是否开启捏合流畅模式,默认不开启
**参数:** **参数:**
...@@ -4373,7 +4380,7 @@ setCookie(url: string, value: string): boolean ...@@ -4373,7 +4380,7 @@ setCookie(url: string, value: string): boolean
Column() { Column() {
Button('setCookie') Button('setCookie')
.onClick(() => { .onClick(() => {
let result = this.controller.getCookieManager().setCookie("www.example.com", "a=b") let result = this.controller.getCookieManager().setCookie("https://www.example.com", "a=b")
console.log("result: " + result) console.log("result: " + result)
}) })
Web({ src: 'www.example.com', controller: this.controller }) Web({ src: 'www.example.com', controller: this.controller })
......
...@@ -61,15 +61,15 @@ GridRow(option?: {columns?: number | GridRowColumnOption, gutter?: Length | Gutt ...@@ -61,15 +61,15 @@ GridRow(option?: {columns?: number | GridRowColumnOption, gutter?: Length | Gutt
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| ----- | ------ | ---- | ---------------------------------------- | | ----- | ------ | ---- | ---------------------------------------- |
| value | Array&lt;string&gt; | 否 | 设置断点位置的单调递增数组。<br>默认值:["320vp", "520vp", "840vp"] | | value | Array&lt;string&gt; | 否 | 设置断点位置的单调递增数组。<br>默认值:["320vp", "600vp", "840vp"] |
| reference | BreakpointsReference | 否 | 断点切换参照物。 | | reference | BreakpointsReference | 否 | 断点切换参照物。 |
```ts ```ts
// 启用xs、sm、md共3个断点 // 启用xs、sm、md共3个断点
breakpoints: {value: ["100vp", "200vp"]} breakpoints: {value: ["100vp", "200vp"]}
// 启用xs、sm、md、lg共4个断点,断点范围值必须单调递增 // 启用xs、sm、md、lg共4个断点,断点范围值必须单调递增
breakpoints: {value: ["320vp", "520vp", "840vp"]} breakpoints: {value: ["320vp", "600vp", "840vp"]}
// 启用xs、sm、md、lg、xl共5个断点,断点范围数量不可超过断点可取值数量-1 // 启用xs、sm、md、lg、xl共5个断点,断点范围数量不可超过断点可取值数量-1
breakpoints: {value: ["320vp", "520vp", "840vp", "1080vp"]} breakpoints: {value: ["320vp", "600vp", "840vp", "1080vp"]}
``` ```
## BreakpointsReference枚举类型 ## BreakpointsReference枚举类型
......
...@@ -374,4 +374,24 @@ The specified bundle does not support clearing of cache files. ...@@ -374,4 +374,24 @@ The specified bundle does not support clearing of cache files.
1.确认指定的应用是否为系统应用,可以使用[bm工具命令](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md%23bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)查询对应的应用信息,查看isSystemApp是否为true。 1.确认指定的应用是否为系统应用,可以使用[bm工具命令](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md%23bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)查询对应的应用信息,查看isSystemApp是否为true。
2.确认指定的应用是否配置了能清除缓存(AllowAppDataNotCleared)的字段,可以使用[bm工具命令](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md%23bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)查询对应的应用信息,查看userDataClearable是否为true。 2.确认指定的应用是否配置了能清除缓存(AllowAppDataNotCleared)的字段,可以使用[bm工具命令](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md%23bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)查询对应的应用信息,查看userDataClearable是否为true。
## 17700031 Overlay特性校验失败导致HAP安装失败
**错误信息**<br/>
Failed to install the HAP because the overlay check of the HAP is failed.
**错误描述**<br/>
当安装overlay特征的应用时,指定的应用和待安装的overlay特征应用不为预置应用,或者目标应用/目标module是overlay特征的应用/module。
**可能原因**<br/>
1. 使用应用间的overlay特性时,overlay特征应用必须为预置应用。
2. 使用应用间的overlay特性时,目标应用必须为预置应用。
3. 使用应用间的overlay特性时,目标应用不能是具有overlay特征的应用
4. 目标module不能是具有overlay特征的module。
**处理步骤**<br/>
1. 检查overlay特征应用是否为预置应用。
2. 检查目标应用是否为预置应用。
3. 检查目标应用是否不为overlay特征的应用
4. 检查目标module是否不为overlay特征的module。
<!--no_check--> <!--no_check-->
\ No newline at end of file
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
| 断点名称 | 取值范围(vp)| | 断点名称 | 取值范围(vp)|
| --------| ------ | | --------| ------ |
| xs | [0, 320) | | xs | [0, 320) |
| sm | [320, 520) | | sm | [320, 600) |
| md | [520, 840) | | md | [600, 840) |
| lg | [840, +∞) | | lg | [840, +∞) |
在GridRow新栅格组件中,允许开发者使用breakpoints自定义修改断点的取值范围,最多支持6个断点,除了默认的四个断点外, 在GridRow新栅格组件中,允许开发者使用breakpoints自定义修改断点的取值范围,最多支持6个断点,除了默认的四个断点外,
...@@ -55,10 +55,10 @@ ...@@ -55,10 +55,10 @@
表示启用xs、sm、md共3个断点,小于100vp为xs,100vp-200vp为sm,大于200vp为md。 表示启用xs、sm、md共3个断点,小于100vp为xs,100vp-200vp为sm,大于200vp为md。
```ts ```ts
breakpoints: {value: ["320vp", "520vp", "840vp", "1080vp"]} breakpoints: {value: ["320vp", "600vp", "840vp", "1080vp"]}
``` ```
表示启用xs、sm、md、lg、xl共5个断点,小于320vp为xs,320vp-520vp为sm,520vp-840vp为md,840vp-1080vp为lg,大于1080vp为xl。 表示启用xs、sm、md、lg、xl共5个断点,小于320vp为xs,320vp-600vp为sm,600vp-840vp为md,840vp-1080vp为lg,大于1080vp为xl。
- 栅格系统通过监听窗口或容器的尺寸变化进行断点,通过reference设置断点切换参考物。 考虑到应用可能以非全屏窗口的形式显示,以应用窗口宽度为参照物更为通用。 - 栅格系统通过监听窗口或容器的尺寸变化进行断点,通过reference设置断点切换参考物。 考虑到应用可能以非全屏窗口的形式显示,以应用窗口宽度为参照物更为通用。
......
...@@ -67,6 +67,7 @@ ohos_shared_library("helloworld") { ...@@ -67,6 +67,7 @@ ohos_shared_library("helloworld") {
sanitize = { sanitize = {
# 各个Sanitizer开关 # 各个Sanitizer开关
cfi = [boolean] # 控制流完整性检测 cfi = [boolean] # 控制流完整性检测
cfi_cross_dso = [boolean] # 开启跨so调用的控制流完整性检测
integer_overflow = [boolean] # 整数溢出检测 integer_overflow = [boolean] # 整数溢出检测
boundary_sanitize = [boolean] # 边界检测 boundary_sanitize = [boolean] # 边界检测
ubsan = [boolean] # 部分ubsan选项 ubsan = [boolean] # 部分ubsan选项
...@@ -114,6 +115,7 @@ ohos_static_library("helloworld") { ...@@ -114,6 +115,7 @@ ohos_static_library("helloworld") {
sanitize = { sanitize = {
# 各个Sanitizer开关 # 各个Sanitizer开关
cfi = [boolean] # 控制流完整性检测 cfi = [boolean] # 控制流完整性检测
cfi_cross_dso = [boolean] # 开启跨so调用的控制流完整性检测
integer_overflow = [boolean] # 整数溢出检测 integer_overflow = [boolean] # 整数溢出检测
boundary_sanitize = [boolean] # 边界检测 boundary_sanitize = [boolean] # 边界检测
ubsan = [boolean] # 部分ubsan选项 ubsan = [boolean] # 部分ubsan选项
...@@ -152,6 +154,7 @@ ohos_executable("helloworld") { ...@@ -152,6 +154,7 @@ ohos_executable("helloworld") {
sanitize = { sanitize = {
# 各个Sanitizer开关 # 各个Sanitizer开关
cfi = [boolean] # 控制流完整性检测 cfi = [boolean] # 控制流完整性检测
cfi_cross_dso = [boolean] # 开启跨so调用的控制流完整性检测
integer_overflow = [boolean] # 整数溢出检测 integer_overflow = [boolean] # 整数溢出检测
boundary_sanitize = [boolean] # 边界检测 boundary_sanitize = [boolean] # 边界检测
ubsan = [boolean] # 部分ubsan选项 ubsan = [boolean] # 部分ubsan选项
...@@ -201,6 +204,7 @@ ohos_source_set("helloworld") { ...@@ -201,6 +204,7 @@ ohos_source_set("helloworld") {
sanitize = { sanitize = {
# 各个Sanitizer开关 # 各个Sanitizer开关
cfi = [boolean] # 控制流完整性检测 cfi = [boolean] # 控制流完整性检测
cfi_cross_dso = [boolean] # 开启跨so调用的控制流完整性检测
integer_overflow = [boolean] # 整数溢出检测 integer_overflow = [boolean] # 整数溢出检测
boundary_sanitize = [boolean] # 边界检测 boundary_sanitize = [boolean] # 边界检测
ubsan = [boolean] # 部分ubsan选项 ubsan = [boolean] # 部分ubsan选项
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
ohos_shared_library("example") { ohos_shared_library("example") {
sanitize = { sanitize = {
cfi = true # 开启控制流完整性检测 cfi = true # 开启控制流完整性检测
cfi_cross_dso = true # 开启跨so调用的控制流完整性检测
integer_overflow = true # 开启整数溢出检测 integer_overflow = true # 开启整数溢出检测
boundary_sanitize = true # 开启边界检测 boundary_sanitize = true # 开启边界检测
ubsan = true # 开启部分ubsan选项 ubsan = true # 开启部分ubsan选项
...@@ -85,7 +86,7 @@ ...@@ -85,7 +86,7 @@
目前支持开启的Sanitizer: 目前支持开启的Sanitizer:
- 整数溢出排错:unsigned_integer_overflow/signed_integer_overflow/integer_overflow(同时包括无符号和有符号整数溢出两种检查) - 整数溢出排错:unsigned_integer_overflow/signed_integer_overflow/integer_overflow(同时包括无符号和有符号整数溢出两种检查)
- 控制流完整性:cfi - 控制流完整性:cfi、cfi_cross_dso(跨so的cfi检查)
- 边界检测:boundary_sanitize - 边界检测:boundary_sanitize
- 部分未定义行为检测:ubsan(bool,integer-divide-by-zero,return,returns-nonnull-attribute,shift-exponent,unreachable,vla-bound等编译选项) - 部分未定义行为检测:ubsan(bool,integer-divide-by-zero,return,returns-nonnull-attribute,shift-exponent,unreachable,vla-bound等编译选项)
- 全量未定义行为检测:all_ubsan(全量undefined behavior sanitizer编译选项) - 全量未定义行为检测:all_ubsan(全量undefined behavior sanitizer编译选项)
......
...@@ -37,3 +37,49 @@ GridItem的forceRebuild属性废弃 ...@@ -37,3 +37,49 @@ GridItem的forceRebuild属性废弃
**适配指导** **适配指导**
如有使用可以直接删除,不影响GridItem功能 如有使用可以直接删除,不影响GridItem功能
## cl.arkui.1 API9 router接口整改。
ohos.router中的enableAlertBeforeBackPage、enableBackPageAlert、disableAlertBeforeBackPage接口名不利于开发者理解,更改为showAlertBeforeBackPage、hideAlertBeforeBackPage。
**变更影响**
router的enableAlertBeforeBackPage、enableBackPageAlert接口需替换为showAlertBeforeBackPage;
disableAlertBeforeBackPage接口需替换为hideAlertBeforeBackPage。
**关键的接口/组件变更**
涉及router.enableAlertBeforeBackPage, router.enableBackPageAlert, router.disableAlertBeforeBackPage。
* 变更前:
```ts
router.enableAlertBeforeBackPage();
router.enableBackPageAlert()
```
* 变更后:
```ts
router.showAlertBeforeBackPage()
```
* 变更前:
```ts
router.disableAlertBeforeBackPage()
```
* 变更后:
```ts
router.hideAlertBeforeBackPage()
```
**适配指导**
将enableAlertBeforeBackPage、enableBackPageAlert替换为showAlertBeforeBackPage;
将disableAlertBeforeBackPage替换为hideAlertBeforeBackPage。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册