提交 962f8639 编写于 作者: X xinking129

Merge remote-tracking branch 'upstream/master' into appRecoveryRestart0329

......@@ -37,18 +37,15 @@ No error will be thrown if the preceding APIs are used in the troubleshooting sc
### Application State Management
Since API version 10, application recovery is not limited to automatic restart in the case of an exception. Therefore, you need to understand when the application will load the saved state.
If the last exit of an application is not initiated by a user and a saved state is available for recovery, the startup reason is set to **APP_RECOVERY** when the application is started by the user next time, and the recovery state of the application is cleared.
The application recovery status flag is set when **saveAppState** is actively or passively called. The flag is cleared when the application exits normally or the saved state is consumed. (A normal exit is usually triggered by pressing the back key or clearing recent tasks.)
![Application recovery status management](./figures/application_recovery_status_management.png)
### Application State Saving and Restore
API version 10 or later supports saving of the application state when an application is suspended. If a JsError occurs, **onSaveState** is called in the main thread. If an AppFreeze occurs, however, the main thread may be suspended, and therefore **onSaveState** is called in a non-main thread. The following figure shows the main service flow.
![Application recovery from the freezing state](./figures/application_recovery_from_freezing.png)
When the application is suspended, the callback is not executed in the JS thread. Therefore, you are advised not to use the imported dynamic Native library or access the **thread_local** object created by the main thread in the code of the **onSaveState** callback.
### Framework Fault Management
......@@ -62,13 +59,9 @@ Fault management is an important way for applications to deliver a better user e
- Fault query is the process of calling APIs of [faultLogger](../reference/apis/js-apis-faultLogger.md) to obtain the fault information.
The figure below does not illustrate the time when [faultLogger](../reference/apis/js-apis-faultLogger.md) is called. You can refer to the [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 information about the previous fault.
![Fault rectification process](./figures/fault_rectification.png)
It is recommended that you call [errorManager](../reference/apis/js-apis-app-ability-errorManager.md) to handle the exception. After the processing is complete, you can call the **saveAppState** API and restart the application.
If you do not register [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) or enable application recovery, the application process will exit according to the default processing logic of the system. Users can restart the application from the home screen.
If you have enabled application recovery, the recovery framework first checks whether application state saving is supported and whether the application state saving is enabled. If so, the recovery framework invokes [onSaveState](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonsavestate) of the [Ability](../reference/apis/js-apis-app-ability-uiAbility.md). Finally, the application is restarted.
### Supported Application Recovery Scenarios
......
......@@ -64,7 +64,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName is greater than 256 bytes. |
**Example**
......@@ -111,7 +111,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName is greater than 256 bytes. |
**Example**
......@@ -154,7 +154,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the flags value is invalid. |
| 12100001 | The parameter is invalid. The tokenID is 0, the permissionName is greater than 256 bytes, or the flags value is invalid. |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
| 12100006 | The application specified by the tokenID is not allowed to be granted with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
......@@ -206,9 +206,9 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the flags value is invalid. |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
| 12100001 | The parameter is invalid. The tokenID is 0, the permissionName is greater than 256 bytes, or the flags value is invalid. |
| 12100002 | TokenId does not exist. |
| 12100003 | Permission does not exist. |
| 12100006 | The application specified by the tokenID is not allowed to be granted with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
| 12100007 | Service is abnormal. |
......@@ -265,7 +265,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the flags value is invalid. |
| 12100001 | The parameter is invalid. The tokenID is 0, the permissionName is greater than 256 bytes, or the flags value is invalid. |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
| 12100006 | The application specified by the tokenID is not allowed to be revoked with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
......@@ -317,9 +317,9 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the flags value is invalid. |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
| 12100001 | The parameter is invalid. The tokenID is 0, the permissionName is greater than 256 bytes, or the flags value is invalid. |
| 12100002 | TokenId does not exist. |
| 12100003 | Permission does not exist. |
| 12100006 | The application specified by the tokenID is not allowed to be revoked with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
| 12100007 | Service is abnormal. |
......@@ -375,7 +375,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName is greater than 256 bytes. |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
| 12100006 | The operation is not allowed. Either the application is a sandbox or the tokenID is from a remote device. |
......@@ -452,7 +452,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName is greater than 256 bytes. |
| 12100004 | The interface is called repeatedly with the same input. |
| 12100005 | The registration time has exceeded the limitation. |
| 12100007 | Service is abnormal. |
......@@ -693,44 +693,6 @@ promise.then(data => {
});
```
### checkAccessTokenSync<sup>10+</sup>
checkAccessTokenSync(tokenID: number, permissionName: Permissions): GrantStatus;
Checks whether a permission is granted to an application. This API returns the result synchronously.
**System capability**: SystemCapability.Security.AccessToken
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ |
| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
| permissionName | Permissions | Yes | Permission to check. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| [GrantStatus](#grantstatus) | Permission grant state.|
**Error codes**
For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
**Example**
```js
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let data = atManager.checkAccessTokenSync(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
console.log(`data->${JSON.stringify(data)}`);
```
### GrantStatus
Enumerates the permission grant states.
......@@ -757,7 +719,7 @@ Enumerates the operations that trigger permission grant state changes.
### PermissionStateChangeInfo<sup>9+</sup>
Defines information about the permission grant state change.
Defines detailed information about the permission grant state change.
**System API**: This is a system API.
......@@ -768,3 +730,4 @@ Defines information about the permission grant state change.
| change | [PermissionStateChangeType](#permissionstatechangetype9) | Yes | No | Operation that triggers the permission grant state change. |
| tokenID | number | Yes | No | Token ID of the application. |
| permissionName | Permissions | Yes | No | Permission whose grant state changes. For details about the permissions, see the [Application Permission List](../../security/permission-list.md). |
......@@ -22,8 +22,7 @@ Obtains the total size (in bytes) of the specified volume in an external storage
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -59,8 +58,7 @@ Obtains the total size (in bytes) of the specified volume in an external storage
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -90,8 +88,7 @@ Obtains the available space (in bytes) of the specified volume in an external st
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -128,8 +125,7 @@ Obtains the available space (in bytes) of the specified volume in an external st
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -159,8 +155,7 @@ Obtains the space (in bytes) of an application. This API uses a promise to retur
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -196,8 +191,7 @@ Obtains the space (in bytes) of an application. This API uses an asynchronous ca
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -263,12 +257,8 @@ Obtains the space (in bytes) of this third-party application. This API uses an a
## BundleStats<sup>9+</sup>
### Attributes
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
| Name | Type | Readable| Writable| Description |
| --------- | ------ | --- | ---- | -------------- |
| appSize | number | Yes| No| Size of the application, in bytes. |
......@@ -286,9 +276,7 @@ Obtains the total size (in bytes) of the built-in storage. This API uses a promi
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Return value**
......@@ -313,9 +301,7 @@ Obtains the total size (in bytes) of the built-in storage. This API uses an asyn
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -343,9 +329,7 @@ Obtains the available space (in bytes) of the built-in storage. This API uses a
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Return value**
......@@ -371,9 +355,7 @@ Obtains the available space (in bytes) of the built-in storage. This API uses an
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -400,8 +382,7 @@ Obtains the system data space, in bytes. This API uses a promise to return the r
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Return value**
......@@ -430,9 +411,7 @@ Obtains the system data space, in bytes. This API uses an asynchronous callback
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -459,9 +438,7 @@ Obtains the storage statistics (in bytes) of this user. This API uses a promise
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Return value**
......@@ -489,9 +466,7 @@ Obtains the storage statistics (in bytes) of this user. This API uses an asynchr
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -515,9 +490,7 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -552,9 +525,7 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
**Parameters**
......@@ -576,12 +547,9 @@ This is a system API.
## StorageStats<sup>9+</sup>
### Attributes
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API.
**System API**: This is a system API.
| Name | Type | Readable | Writable | Description |
| --------- | ------ | ---- | ----- | -------------- |
......
......@@ -3,7 +3,7 @@
> **NOTE**
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>- The APIs provided by this module are deprecated since API version 9. You are advised to use [cryptoFramework-Cipher](js-apis-cryptoFramework.md#Cipher).
>- The APIs provided by this module are deprecated since API version 9. You are advised to use [@ohos.security.cryptoFramework Cipher](js-apis-cryptoFramework.md#cipher).
## Modules to Import
......
......@@ -4,72 +4,75 @@
## Overview
### Function
### Function Introduction
FaultLogger is a maintenance and debugging log framework provided by OpenHarmony. It enables unified detection, log collection, log storage, and log reporting for application, ability, and system service process crashes. It is available for the standard system and the Linux kernel-based small system.
FaultLogger is responsible for fault recording of OpenHarmony. It runs on the following two components based on the service object:
- HiView: serves functional modules at the application layer and native layer. It manages various fault information in the system and provides APIs for modules to query faults.
- Hiview: serves functional modules at the application layer and native layer. It manages various fault information in the system and provides APIs for modules to query faults.
- FaultLoggerd: serves the crash process. It collects information about abnormal daemon processes in C/C++ and obtains the process call stack.
- Faultloggerd: serves the crash process. It collects information about the abnormal daemon process in C/C++ and obtains call stack information of the process.
The following figure shows the process of handling a process crash based on the FaultLogger service.
**Figure 1** Process crash handling flowchart
![process_crash_handling](figures/process_crash_handling.png)
![Process crash handling flowchart](figures/process_crash_handling_flowchart.png)
1. After the signal processor is installed, the **DFX_SignalHandler** function detects and responds to the process crash exception signal.
1. After the signal processor is installed, SignalHandler uses the **DFX_SignalHandler** function to detect and respond to the process crash exception signal thrown by the kernel.
2. **SignalHandler** forks a child process after detecting the exception signal and runs **ProcessDump** to dump the stack information of the crashed process and thread.
2. When detecting a process crash exception signal, SignalHandler forks a child process and runs ProcessDump to dump the stack information of the crashed process and thread.
3. **ProcessDump** then writes a log to the temporary storage directory in FaultLoggerd, generating a full crash log.
3. ProcessDump applies to Faultloggerd for a file handle for storing fault logs. After reading the exception stack information, ProcessDump writes the information to the file to generate a complete crash log.
4. FaultLoggerd reports the fault through the **AddFaultLog()** API provided by HiView. HiView handles the fault, generates a simple crash log, and reports a HiSysEvent.
4. After collecting the complete crash log, ProcessDump reports the log to Hiview by using the **AddFaultLog()** API. Hiview generates a simplified crash log and reports a system event through HiSysEvent.
With this design, a small-system with limited resources can obtain logs for locating crash faults as long as FaultLoggerd is deployed.
With this design, a small-system with limited resources can obtain logs for locating crash faults as long as Faultloggerd is deployed.
### Use Cases
FaultLoggerd provides a lightweight approach for you to locate crash or suspension problems during development and testing.
Faultloggerd provides a lightweight approach for you to locate crash or suspension problems during development and testing.
It is applicable to the following scenarios:
The following table describes the application scenarios.
**Table 1** Application scenarios of the Faultloggerd module
| Scenario| Tool| Usage|
| -------- | -------- | -------- |
| To understand the function call sequence| DumpCatcher&nbsp;API | See [Using DumpCatcher to Obtain the Call Stack](#using-dumpcatcher-to-obtain-the-call-stack).|
| Application suspension or high CPU usage| ProcessDump | See [Using ProcessDump to Obtain the Call Stack](#using-processdump-to-obtain-the-call-stack).|
| Signal crash not handled by the process| Crash log and addr2line tool| See [Locating Faults Based on Crash Logs](#locating-faults-based-on-crash-logs).|
| Understanding of the function call sequence| DumpCatcher API | See [Using DumpCatcher APIs to Obtain Call Stack Information](#using-dumpcatcher-apis-to-obtain-call-stack-information).|
| Application suspension or high CPU usage| DumpCatcher Command Tool | See [Using DumpCatcher Commands to Obtain Call Stack Information](#using-dumpcatcher-commands-to-obtain-call-stack-information).|
| Crash fault location| Crash log and addr2line tool| For details, see [Locating Faults Based on the Crash Log](#locating-faults-based-on-the-crash-log).|
## Using DumpCatcher to Obtain the Call Stack
## Using DumpCatcher APIs to Obtain Call Stack Information
### Available APIs
DumpCatcher can capture the call stack of a specified process (thread) on OpenHarmony.
DumpCatcher can capture the call stack information of the specified process (thread) on OpenHarmony.
Table 2 DumpCatcher APIs
**Table 2** DumpCatcher APIs
| Class| API| Description|
| -------- | -------- | -------- |
| DfxDumpCatcher | bool&nbsp;DumpCatch(const&nbsp;int&nbsp;pid,&nbsp;const&nbsp;int&nbsp;tid,&nbsp;std::string&amp;&nbsp;msg) | Return value:<br>**true**: Back trace is successful. Related information is stored in the **msg** string object.<br>**false**: Back trace failed.<br>Input arguments:<br>**pid**: target process ID.<br>**tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.<br>Output argument:<br>**msg**: return message. If back trace is successful, the call stack information is returned through **msg**.|
| DfxDumpCatcher | bool DumpCatch(const int pid, const int tid, std::string&amp; msg) | Return value:<br>- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.<br>- **false**: Dumping of stack information has failed.<br> Input arguments:<br>- **pid**: target process ID.<br>- **tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.<br> Output arguments:<br>- **msg**: If back trace is successful, call stack information is returned through **msg**.|
| DfxDumpCatcher | bool DumpCatchMix(const int pid, const int tid, std::string&amp; msg) | Return value:<br>- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.<br>- **false**: Dumping of stack information has failed.<br> Input arguments:<br>**pid**: target process ID.<br>- **tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.<br> Output arguments:<br>- **msg**: If back trace is successful, hybrid stack information is returned through **msg**.|
| DfxDumpCatcher | bool DumpCatchFd(const int pid, const int tid, std::string&amp; msg, int fd) | Return value:<br>- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.<br>- **false**: Dumping of stack information has failed.<br> Input arguments:<br>**pid**: target process ID.<br>- **tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.<br>- **fd**: handle of the file to be written.<br> Output parameters:<br>- **msg**: If back trace is successful, call stack information is returned through **msg**.|
| DfxDumpCatcher | bool DumpCatchMultiPid(const std::vector\<int> pidV, std::string&amp; msg) | Return value:<br>- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.<br>- **false**: Dumping of stack information has failed.<br> Input arguments:<br>- **pidV**: target process ID list.<br> Output arguments:<br>- **msg**: If back trace is successful, call stack information is returned through **msg**.|
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If the PID that calls this API is different from the target PID, the caller must be the **system** or **root** user. To capture the call stack of a process that does not belong to the current user group, ensure that you have permissions to read **/proc/pid/maps** and implement **ptrace** on the peer process.
> **NOTE**
> If the PID that calls this API is different from the target PID, the caller must be the **system** or **root** user.
### Development Example
### How to Develop
You can use DumpCatcher to obtain the call stack of a specified process (thread) in your applications. The following uses the **dumpcatcherdemo** module as an example to describe how to use the DumpCatcher API to obtain the call stack.
You can use DumpCatcher to obtain call stack information for the specified process (thread) of an application. The following uses the **dumpcatcherdemo** module as an example to describe how to use the DumpCatcher APIs to obtain the call stack information.
1. Add the DumpCatcher dependency to the build file. Take /base/hiviewdfx/faultloggerd/example/BUILD.gn as an example. Add the **dfx_dump_catcher.h** file path to **include_dirs** and add the required **//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher** module to **deps**.
1. Add the DumpCatcher dependency to the build file. Take /base/hiviewdfx/faultloggerd/example/BUILD.gn as an example. Add the **dump_catcher.h** file path to **include_dirs** and add the required **//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher** module to **deps**.
```
import("//base/hiviewdfx/faultloggerd/faultloggerd.gni")
......@@ -85,7 +88,17 @@ You can use DumpCatcher to obtain the call stack of a specified process (thread)
]
}
ohos_executable("dumpcatcherdemo") { sources = [ "dump_catcher_demo.cpp" ] configs = [ ":dumpcatcherdemo_config" ] deps = [ "//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher", # Add the DumpCatcher module dependency. "//utils/native/base:utils", ] external_deps = [ "hilog_native:libhilog" ] install_enable = true part_name = "faultloggerd" subsystem_name = "hiviewdfx"
ohos_executable("dumpcatcherdemo") {
sources = [ "dump_catcher_demo.cpp" ]
configs = [ ":dumpcatcherdemo_config" ]
deps = [
"//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher", # Add the DumpCatcher module dependency.
"//utils/native/base:utils",
]
external_deps = [ "hilog_native:libhilog" ]
install_enable = true
part_name = "faultloggerd"
subsystem_name = "hiviewdfx"
}
```
......@@ -138,7 +151,7 @@ You can use DumpCatcher to obtain the call stack of a specified process (thread)
{
OHOS::HiviewDFX::DfxDumpCatcher dumplog;
string msg = "";
bool ret = dumplog.DumpCatch(getpid(), gettid(), msg); // Call the DumpCatch API to obtain the call stack.
bool ret = dumplog.DumpCatch(getpid(), gettid(), msg); // Call the DumpCatch API to obtain the call stack information.
if (ret) {
cout << msg << endl;
}
......@@ -165,50 +178,52 @@ You can use DumpCatcher to obtain the call stack of a specified process (thread)
```
## Using ProcessDump to Obtain the Call Stack
## Using DumpCatcher Commands to Obtain Call Stack Information
### Tool Description
ProcessDump is a command line interface (CLI) based tool for capturing call stacks on OpenHarmony. It uses the **-p** and **-t** parameters to specify the process and thread. After the command is executed, the thread stack information of the specified process is displayed in the CLI window.
DumpCatcher Command Tool is a command line interface (CLI)-based tool for capturing call stack information on OpenHarmony. It uses the **-p** and **-t** parameters to specify the process and thread. After the command is executed, the thread stack information of the specified process is displayed in the CLI window. By specifying the **-m** parameter, you can also capture the JS and Native hybrid stack information of an application process.
**Table 3** Usage of the CLI-based ProcessDump
**Table 3** Usage of the DumpCatcher Command Tool
| Tool| Path| Command| Description|
| -------- | -------- | -------- | -------- |
| processdump | /system/bin | -&nbsp;processdump&nbsp;-p&nbsp;[pid]<br>-&nbsp;processdump&nbsp;-p&nbsp;[pid]&nbsp;-t&nbsp;[tid] | **Arguments:**<br>**- -p [pid]**: prints stack information for all threads of the specified process.<br>**- -p [pid] -t [tid]**: prints information for the specified thread of the specified process.<br>**Return value:**<br>If the stack information is parsed successfully, the information is displayed in the standard output. If the stack information fails to be parsed, error information is displayed.|
| dumpcatcher | /system/bin | - dumpcatcher -p [pid]<br>- dumpcatcher -p [pid] -t [tid]<br>- dumpcatcher -m -p [pid]<br>- dumpcatcher -m -p [pid] -t [tid]<br>| **Description:**<br>- **-p [pid]**: prints all thread stack information of the specified process.<br>- **-p [pid] -t [tid]**: prints stack information for the specified thread of the specified process.<br>- **-m -p [pid]**: prints hybrid stack information for all threads of the specified process.<br>- **-m -p [pid] -t [tid]**: prints hybrid stack information for the specified thread of the specified process.<br>**Return value:**<br>If the stack information is parsed successfully, the information is displayed in the standard output. If the stack information fails to be parsed, error information is displayed.|
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> This tool must be used by the **root** user, or the caller must have the permission to ptrace the target process and read the smaps of the target process.
### Development Example
### Example
Use ProcessDump to print the call stack of the **hiview** process.
Print call stack information of the **hiview** process.
```
# ps -A | grep hiview
114 ? 00:00:00 hiview
# processdump -p 114 -t 114
Tid:114, Name:hiview
#00 pc 0000000000089824(00000000b6f44824) /system/lib/ld-musl-arm.so.1(ioctl+68)
#01 pc 000000000002a709(00000000b6c56709) /system/lib/libipc_core.z.so(_ZN4OHOS15BinderConnector11WriteBinderEmPv+16)
#02 pc 000000000002ba75(00000000b6c57a75) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker18TransactWithDriverEb+224)
#03 pc 000000000002bb37(00000000b6c57b37) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker13StartWorkLoopEv+22)
#04 pc 000000000002c211(00000000b6c58211) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker10JoinThreadEb+36)
#05 pc 0000000000038d07(00000000004bcd07) /system/bin/hiview(_ZNSt3__h6vectorINS_9sub_matchINS_11__wrap_iterIPKcEEEENS_9allocatorIS6_EEE8__appendEj+596)
#06 pc 0000000000028655(00000000004ac655) /system/bin/hiview
#07 pc 00000000000c2b08(00000000b6f7db08) /system/lib/ld-musl-arm.so.1(__libc_start_main+116)
#08 pc 00000000000285f4(00000000004ac5f4) /system/bin/hiview
#09 pc 0000000000028580(00000000004ac580) /system/bin/hiview
# ps -ef |grep hiview
hiview 240 1 0 17:01:49 ? 00:00:14 hiview
root 1822 1560 7 20:56:36 pts/0 00:00:00 grep hiview
# dumpcatcher -p 240 -t 240
Result: 0 ( no error )
Timestamp:2017-08-05 20:56:43.000
Pid:240
Uid:1201
Process name:/system/bin/hiview
Tid:240, Name:hiview
#00 pc 00098f8c /system/lib/ld-musl-arm.so.1(ioctl+68)
#01 pc 0000e2a1 /system/lib/chipset-pub-sdk/libipc_single.z.so
#02 pc 0000ed59 /system/lib/chipset-pub-sdk/libipc_single.z.so
#03 pc 0000ee1f /system/lib/chipset-pub-sdk/libipc_single.z.so
#04 pc 0000f745 /system/lib/chipset-pub-sdk/libipc_single.z.so
#05 pc 00037577 /system/bin/hiview
#06 pc 00025973 /system/bin/hiview
#07 pc 000db210 /system/lib/ld-musl-arm.so.1
#08 pc 000258d8 /system/bin/hiview
#09 pc 0002587c /system/bin/hiview
```
## Locating Faults Based on Crash Logs
## Locating Faults Based on the Crash Log
You can locate faults based on the crash stack logs generated by FaultLoggerd. This section describes how to use the addr2line tool to locate a crash fault.
You can locate faults based on the crash stack logs generated by Faultloggerd. This section describes how to use the addr2line tool to locate a crash fault.
1. Find a program crash or construct a crash.
For example, insert the following code into your code to trigger an invalid memory access fault (SIGSEGV).
......@@ -233,35 +248,36 @@ You can locate faults based on the crash stack logs generated by FaultLoggerd. T
cppcrash-pid-time
```
The generated call stack is as follows:
The generated call stack information is as follows:
```
Timestamp:2017-08-05 17:35:03.000
Pid:816
Uid:0
Process name:./crasher
Process name:./crasher_c
Reason:Signal:SIGSEGV(SEGV_ACCERR)@0x0042d33d
Fault thread Info:
Tid:816, Name:crasher
#00 pc 0000332c /data/crasher(TriggerSegmentFaultException+15)(8bc37ceb8d6169e919d178fdc7f5449e)
#01 pc 000035c7 /data/crasher(ParseAndDoCrash+277)(8bc37ceb8d6169e919d178fdc7f5449e)
#02 pc 00003689 /data/crasher(main+39)(8bc37ceb8d6169e919d178fdc7f5449e)
#03 pc 000c3b08 /system/lib/ld-musl-arm.so.1(__libc_start_main+116)
#04 pc 000032f8 /data/crasher(_start_c+112)(8bc37ceb8d6169e919d178fdc7f5449e)
#05 pc 00003284 /data/crasher(_start+32)(8bc37ceb8d6169e919d178fdc7f5449e)
Registers:
r0:0042d33d r1:0000000b r2:1725d4c4 r3:b6f9fa84
r4:bec97e69 r5:b6fc0268 r6:0042d661 r7:bec97d60
r8:00000000 r9:00000000 r10:00000000
fp:bec97d20 ip:00000020 sp:bec97cd0 lr:b6f9fae4 pc:0042d32c
#00 pc 000000000000332c(000000000042d32c) /data/crasher(TriggerSegmentFaultException+15)
#01 pc 00000000000035c7(000000000042d5c7) /data/crasher(ParseAndDoCrash+277)
#02 pc 0000000000003689(000000000042d689) /data/crasher(main+39)
#03 pc 00000000000c3b08(00000000b6fbbb08) /system/lib/ld-musl-arm.so.1(__libc_start_main+116)
#04 pc 00000000000032f8(000000000042d2f8) /data/crasher(_start_c+112)
#05 pc 0000000000003284(000000000042d284) /data/crasher(_start+32)
```
3. Use the addr2line tool to analyze the call stack.
3. Use the addr2line tool to analyze the call stack information.
Then, parse the line number based on the offset address.
```
root:~/OpenHarmony/out/hi3516dv300/exe.unstripped/hiviewdfx/faultloggerd$ addr2line -e crasher 000332c
root:~/OpenHarmony/out/hi3516dv300/exe.unstripped/hiviewdfx/faultloggerd$ addr2line -e crasher 0000332c
base/hiviewdfx/faultloggerd/tools/crasher/dfx_crasher.c:57
```
......
......@@ -28,8 +28,7 @@ Constraints on the event domain, event name, and parameter
- Zero or more event names can be defined for one event domain. The event names in the same event domain must be unique.
- Multiple parameters can be defined for one event name. The parameters in the same event name must be unique. There must be only one parameter named **__BASE** in each event name. See Table 1 for the fields of this parameter and Table 2 for the fields of other custom parameters.
- Multiple parameters can be defined for one event name. The parameters in the same event name must be unique. There must be only one parameter named **\__BASE** in each event name. See Table 1 for the fields of this parameter and Table 2 for the fields of other custom parameters.
**Table 1** Fields in the \__BASE parameter
| Field| Description|
......@@ -47,8 +46,10 @@ Constraints on the event domain, event name, and parameter
| arrsize | Length of the parameter of the array type. This field is optional.<br>Value:<br>1-100|
| desc | Parameter description. This field is mandatory.<br>Rule:<br>The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).|
## How to Develop
### Writing a YAML File
......
# HiSysEvent Overview
# HiSysEvent
## Introduction
......
......@@ -2,7 +2,7 @@
## Introduction
HiTraceMeter is the OpenHarmony subsystem that provides APIs to implement call chain trace throughout a service process. With HiTraceMeter, you can quickly obtain the run log specific to the call chain of a service process and locate faults in inter-device, inter-process, or inter-thread communications. HiTraceMeter supports event logging in user mode and can collect trace data in user mode and kernel mode for performance tracing and analysis.
HiTraceMeter is the OpenHarmony subsystem that provides APIs to implement call chain trace throughout a service process. With HiTraceMeter, you can quickly obtain the run log specific to the call chain of a service process and locate faults in inter-device, inter-process, or inter-thread communications. HiTraceMeter supports event logging in user mode and can collect trace data in user mode and kernel mode for performance trace and analysis.
## Basic Concepts
......@@ -12,7 +12,7 @@ The HiTraceMeter subsystem consists of three parts:
- hitrace CLI tool for data collection
- smartperf tool for graphical data analysis
Wherein, HiTraceMeter APIs and the hitrace CLI tool run on the device side, and the smartperf tool runs on the PC side. HiTraceMeter APIs are provided in C++ and JS for event logging, which aims to generate the trace data necessary for performance tracing and analysis during the development process.
Wherein, HiTraceMeter APIs and the hitrace CLI tool run on the device side, and the smartperf tool runs on the PC side. HiTraceMeter APIs are provided in C++ and JS for event logging, which aims to generate the trace data necessary for performance trace and analysis during the development process.
The hitrace CLI tool is used to collect trace data. It captures trace data flows and saves the data as a text file.
......@@ -348,4 +348,4 @@ You can set **-t** to **60** and **-b** to **204800** to increase the trace time
# Reference
For details about HiTraceMeter, see [hiviewdfx_hitrace: Lightweight Distributed Tracing](https://gitee.com/openharmony/hiviewdfx_hitrace).
For details about HiTraceMeter, see [hiviewdfx_hitrace: Lightweight Distributed Trace](https://gitee.com/openharmony/hiviewdfx_hitrace).
# DFX Overview<a name="EN-US_TOPIC_0000001185974398"></a>
# DFX Overview
## Introduction
[Design for X](https://en.wikipedia.org/wiki/Design_for_X) \(DFX\) refers to the software design that aims to improve the quality attributes in OpenHarmony. It mainly consists of two parts: design for reliability \(DFR\) and design for testability \(DFT\).
The DFX subsystem provides the following functions:
- HiLog: implements the logging function. It is applicable to mini-system devices \(reference memory ≥ 128 KiB\), small-system devices \(reference memory ≥ 1 MiB\), and standard-system devices \(reference memory ≥ 128 MB\).
- HiTraceChain: implements distributed call chain tracing. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- HiLog: implements the logging function. It is applicable to mini-system devices \(reference memory ≥ 128 KiB\), small-system devices \(reference memory ≥ 1 MiB\), and standard-system devices \(reference memory ≥ 128 MiB\).
- HiTraceChain: implements distributed call chain trace. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- HiTraceMeter: implements performance trace. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- HiCollie: implements thread suspension detection. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- HiSysEvent: implements system event logging. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- HiDumper: exports system information. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- FaultLogger: implements crash detection. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- Faultlogger: implements crash detection. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- Hiview: implements device maintenance across different platforms. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- HiAppEvent and HiChecker are only hap developer oriented。
- HiAppEvent and HiChecker are applicable only for HAP developers.
![dfx features overview](figure/dfx-overview.png)
## Basic Concepts<a name="section5635178134811"></a>
## Basic Concepts
**Logging**
Logging means to record the log information generated during system running so you can understand the running process and status of the system or applications.
**Distributed call chain tracing**
**Distributed call chain trace**
In a distributed system, the initiation of a service may involve multiple software modules, with control commands and data transmitted over intra-process, inter-process, and inter-device communication interfaces. To help you understand such complex communication processes and locate service faults efficiently, the DFX subsystem provides a distributed call chain tracing framework.
In a distributed system, the initiation of a service may involve multiple software modules, with control commands and data transmitted over intra-process, inter-process, and inter-device communication interfaces. To help you understand such complex communication processes and locate service faults efficiently, the DFX subsystem provides a distributed call chain trace framework.
**Thread suspension detection**
If a thread is trapped in an infinite loop or the kernel state \(for example, Uninterruptable Sleep, Traced, Zombie, or synchronous wait\) when it is running, the thread cannot respond to normal service requests and cannot detect and recover from faults by itself. To detect and locate this type of faults, the DFX subsystem provides a simple watchdog mechanism by inserting detection probes to the process nodes that are prone to suspension. This ensures that suspension faults can be detected and logs can be collected.
If a thread is trapped in an infinite loop or the kernel state (for example, Uninterruptable Sleep, Traced, Zombie, or synchronous wait) when it is running, the thread cannot respond to normal service requests and cannot detect and recover from faults by itself. To detect and locate this type of faults, the DFX subsystem provides a simple watchdog mechanism by inserting detection probes to the process nodes that are prone to suspension. This ensures that suspension faults can be detected and logs can be collected.
**Event logging**
**Logging**
Event logging means to collect and log events reported during system running. The log information will help you better analyze the product usage.
......
# OpenHarmony 1.0 \(2020-09-10)
# OpenHarmony 1.0 \(2020-09-10) (EOL)
## Overview
......
# OpenHarmony 1.1.0 LTS \(2021-04-01\)
# OpenHarmony 1.1.0 LTS \(2021-04-01\) (EOL)
## Overview
......
# OpenHarmony 1.1.1 LTS \(2021-06-22)
# OpenHarmony 1.1.1 LTS \(2021-06-22) (EOL)
## Version Description
......
# OpenHarmony v1.1.3 LTS
# OpenHarmony v1.1.3 LTS (EOL)
## Overview
......
# OpenHarmony 1.1.4 LTS
# OpenHarmony 1.1.4 LTS (EOL)
## Version Description
......
# OpenHarmony v1.1.2 LTS
# OpenHarmony v1.1.2 LTS (EOL)
## Overview
......
# OpenHarmony 1.1.5 LTS
# OpenHarmony 1.1.5 LTS (EOL)
## Version Description
......
......@@ -87,8 +87,8 @@ repo forall -c 'git lfs pull'
| Hi3516 standard system solution (binary)| 3.1.2 Release | [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/standard_hi3516.tar.gz)| [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/standard_hi3516.tar.gz.sha256)|
| RK3568 standard system solution (binary)| 3.1.2 Release | [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/standard_rk3568.tar.gz)| [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/standard_rk3568.tar.gz.sha256)|
| Hi3861 mini system solution (binary)| 3.1.2 Release | [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_pegasus.tar.gz)| [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_pegasus.tar.gz.sha256)|
| Hi3516 mini system solution - LiteOS (binary)| 3.1.2 Release | [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus.tar.gz)| [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus.tar.gz.sha256)|
| Hi3516 mini system solution - Linux (binary)| 3.1.2 Release | [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus_linux.tar.gz)| [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus_linux.tar.gz.sha256)|
| Hi3516 small system solution - LiteOS (binary)| 3.1.2 Release | [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus.tar.gz)| [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus.tar.gz.sha256)|
| Hi3516 small system solution - Linux (binary)| 3.1.2 Release | [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus_linux.tar.gz)| [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus_linux.tar.gz.sha256)|
| Full SDK package for the standard system (macOS)| 3.1.7.5 | [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-mac-full.tar.gz)| [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-mac-full.tar.gz.sha256)|
| Full SDK package for the standard system (Windows/Linux)| 3.1.7.5 | [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-full.tar.gz)| [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-full.tar.gz.sha256)|
| Public SDK package for the standard system (macOS)| 3.1.7.5 | [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-mac-public.tar.gz)| [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-mac-public.tar.gz.sha256)|
......
......@@ -77,7 +77,7 @@ repo forall -c 'git lfs pull'
| -------- | -------- | -------- | -------- |
| Full code base (for mini, small, and standard systems)| 3.1.3 Release | [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/code-v3.1.3-Release.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/code-v3.1.3-Release.tar.gz.sha256)|
| Hi3516 standard system solution (binary)| 3.1.3 Release| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/standard_hi3516.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/standard_hi3516.tar.gz.sha256)|
| RK3568 standard system solution (binary)| 3.1.3 Release| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/code-v3.1.3-Release.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/standard_rk3568.tar.gz.sha256)|
| RK3568 standard system solution (binary)| 3.1.3 Release| [Download](https://mirrors.huaweicloud.com/harmonyos/os/3.1.3/standard_rk3568.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/standard_rk3568.tar.gz.sha256)|
| Hi3861 mini system solution (binary)| 3.1.3 Release| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_pegasus.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_pegasus.tar.gz.sha256)|
| Hi3516 small system solution - LiteOS (binary)| 3.1.3 Release| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus.tar.gz.sha256)|
| Hi3516 small system solution - Linux (binary)| 3.1.3 Release| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus_linux.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus_linux.tar.gz.sha256)|
......
......@@ -7,6 +7,8 @@
- [OpenHarmony v3.2 Beta2 (2022-07-30)](OpenHarmony-v3.2-beta2.md)
- [OpenHarmony v3.2 Beta1 (2022-05-31)](OpenHarmony-v3.2-beta1.md)
- [OpenHarmony v3.1 Release (2022-03-30)](OpenHarmony-v3.1-release.md)
- [OpenHarmony v3.1.6 Release (2023-01-30)](OpenHarmony-v3.1.6-release.md)
- [OpenHarmony v3.1.5 Release (2022-12-30)](OpenHarmony-v3.1.5-release.md)
- [OpenHarmony v3.1.4 Release (2022-11-02)](OpenHarmony-v3.1.4-release.md)
- [OpenHarmony v3.1.3 Release (2022-09-30)](OpenHarmony-v3.1.3-release.md)
- [OpenHarmony v3.1.2 Release (2022-08-24)](OpenHarmony-v3.1.2-release.md)
......@@ -25,7 +27,7 @@
- [OpenHarmony v2.2 beta2 (2021-08-04)](OpenHarmony-v2.2-beta2.md)
- [OpenHarmony 2.0 Canary (2021-06-01)](OpenHarmony-2-0-Canary.md)
## OpenHarmony 1.x Releases
## OpenHarmony 1.x Releases(EOL)
- [OpenHarmony v1.0 (2020-09-10)](OpenHarmony-1-0.md)
- [OpenHarmony v1.1.5 LTS (2022-08-24)](OpenHarmony-v1.1.5-LTS.md)
......
......@@ -52,11 +52,11 @@ function implicitStartAbility() {
let context = getContext(this) as common.UIAbilityContext;
let wantInfo = {
// uncomment line below if wish to implicitly query only in the specific bundle.
// bundleName: "com.example.myapplication",
"action": "ohos.want.action.viewData",
// bundleName: 'com.example.myapplication',
'action': 'ohos.want.action.viewData',
// entities can be omitted.
"entities": ["entity.system.browsable"],
"uri": "https://www.test.com:8080/query/student"
'entities': ['entity.system.browsable'],
'uri': 'https://www.test.com:8080/query/student'
}
context.startAbility(wantInfo).then(() => {
// ...
......@@ -73,5 +73,5 @@ function implicitStartAbility() {
3. 待匹配Ability的skills配置中内uris拼接为`https://www.test.com:8080/query*` (其中*表示通配符),包含调用方传入的want参数的uri,uri匹配成功。
4. 调用方传入的want参数的type不为空,待匹配Ability的skills配置中的type不为空且包含调用方传入的want参数的type,type匹配成功。
有多个匹配应用时,会被应用选择器展示给用户进行选择。 示意效果如下图所示。
存在多个匹配的应用时,系统将弹出应用选择框供用户选择。示意效果如下图所示。
![](figures/ability-startup-with-implicit-want1.png)
......@@ -43,7 +43,7 @@
- 获取[AbilityStageContext](../reference/apis/js-apis-inner-application-abilityStageContext.md)。Module级别的Context,和基类Context相比,额外提供HapModuleInfo、Configuration等信息。
```ts
import AbilityStage from "@ohos.app.ability.AbilityStage";
import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
let abilityStageContext = this.context;
......@@ -80,17 +80,17 @@
从Context中获取的应用开发路径如下表所示。
**表1** 应用开发路径说明
**表1** 应用开发路径说明
| 属性名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| cacheDir | string | 是 | 否 | 应用在内部存储上的缓存路径。<br/>对应于"设置&nbsp;&gt;&nbsp;应用管理",找到对应应用的"存储"中的缓存内容。 |
| tempDir | string | 是 | 否 | 应用的临时文件路径。<br/>在应用卸载后,系统会删除存储在此目录中的文件。 |
| filesDir | string | 是 | 否 | 应用在内部存储上的文件路径。<br/>本目录下存放的文件可能会被应用迁移或者备份的时候同步到其他目录中。 |
| databaseDir | string | 是 | 否 | 获取本地数据库存储路径。 |
| bundleCodeDir | string | 是 | 否 | 应用在内部存储上的安装路径。 |
| distributedFilesDir | string | 是 | 否 | 应用的分布式文件路径。 |
| preferencesDir | string | 是 | 是 | 指示应用程序首选项目录。 |
| bundleCodeDir | string | 是 | 否 | 安装文件路径。应用在内部存储上的安装路径。 |
| cacheDir | string | 是 | 否 | 应用缓存文件路径。应用在内部存储上的缓存路径。<br/>对应于“设置&nbsp;&gt;&nbsp;应用管理”,找到对应应用的“存储”中的缓存内容。 |
| filesDir | string | 是 | 否 | 应用通用文件路径。应用在内部存储上的文件路径。<br/>本目录下存放的文件可能会被应用迁移或者备份的时候同步到其他目录中。 |
| preferencesDir | string | 是 | 是 | 应用首选项文件路径。指示应用程序首选项目录。 |
| tempDir | string | 是 | 否 | 应用临时文件路径。<br/>在应用卸载后,系统会删除存储在此目录中的文件。 |
| databaseDir | string | 是 | 否 | 数据库路径。获取本地数据库存储路径。 |
| distributedFilesDir | string | 是 | 否 | 应用分布式文件路径。 |
获取路径的能力是基类Context中提供的能力,因此在ApplicationContext、AbilityStageContext、UIAbilityContext和ExtensionContext中均可以获取,在各类Context中获取到的路径会有一些差别,具体差别如下图所示。
......@@ -198,7 +198,7 @@ export default class EntryAbility extends UIAbility {
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
let bundleName2 = "com.example.application";
let bundleName2 = 'com.example.application';
let context2 = this.context.createBundleContext(bundleName2);
let label2 = context2.applicationInfo.label;
// ...
......@@ -208,9 +208,10 @@ export default class EntryAbility extends UIAbility {
- 调用createModuleContext(bundleName:string, moduleName:string)方法,获取指定应用指定Module的上下文信息。获取到指定应用指定Module的Context之后,即可获取到相应应用Module的资源信息。
> **说明:**
>
> 当获取的是其他应用的指定Module的Context时:
>
> - 申请`ohos.permission.GET_BUNDLE_INFO_PRIVILEGED`权限,配置方式请参见[访问控制授权申请](../security/accesstoken-guidelines.md#配置文件权限声明)。
> - 申请`ohos.permission.GET_BUNDLE_INFO_PRIVILEGED`权限,配置方式请参见[配置文件权限声明](../security/accesstoken-guidelines.md#配置文件权限声明)。
>
> - 接口为系统接口,三方应用不支持调用。
......@@ -219,8 +220,8 @@ export default class EntryAbility extends UIAbility {
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
let bundleName2 = "com.example.application";
let moduleName2 = "module1";
let bundleName2 = 'com.example.application';
let moduleName2 = 'module1';
let context2 = this.context.createModuleContext(bundleName2, moduleName2);
// ...
}
......@@ -234,7 +235,7 @@ export default class EntryAbility extends UIAbility {
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
let moduleName2 = "module1";
let moduleName2 = 'module1';
let context2 = this.context.createModuleContext(moduleName2);
// ...
}
......@@ -306,7 +307,7 @@ export default class EntryAbility extends UIAbility {
// 获取应用上下文
let applicationContext = this.context.getApplicationContext();
// 注册应用内生命周期回调
this.lifecycleId = applicationContext.on("abilityLifecycle", abilityLifecycleCallback);
this.lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback);
console.log(TAG, `register callback number: ${this.lifecycleId}`);
}
......@@ -316,7 +317,7 @@ export default class EntryAbility extends UIAbility {
// 获取应用上下文
let applicationContext = this.context.getApplicationContext();
// 取消应用内生命周期回调
applicationContext.off("abilityLifecycle", this.lifecycleId);
applicationContext.off('abilityLifecycle', this.lifecycleId);
}
}
```
......@@ -2,20 +2,20 @@
在应用使用场景中,用户经常需要将应用内的数据(如文字、图片等)分享至其他应用以供进一步处理。以分享PDF文件为例,本文将介绍如何使用Want来实现应用间的数据分享。
数据分享需要使用两个UIAbility组件(分享方和被分享方)以及一个系统组件(应用选择框)。当分享方使用`startAbility()`方法发起数据分享时,系统会隐式匹配所有支持接收分享数据类型的应用,并将其展示给用户以供选择。用户选择应用后,系统将启动该应用来完成数据分享操作。
数据分享需要使用两个UIAbility组件(分享方和被分享方)以及一个系统组件(应用分享框)。当分享方使用`startAbility()`方法发起数据分享时,系统会隐式匹配所有支持接收分享数据类型的应用,并将其展示给用户以供选择。用户选择应用后,系统将启动该应用来完成数据分享操作。
在本文中,我们将使用按钮的形式触发分享操作,但实际开发中并不限于此。本文主要介绍如何配置Want以实现数据分享的功能。
本文中涉及的两个Action为:
- `ohos.want.action.select`:用于启动应用选择框。
- `ohos.want.action.select`:用于启动应用分享框。
- `ohos.want.action.sendData`:用于发送单个数据记录。此Action用于将数据传递给分享方应用。
## 分享方
为了实现数据分享功能,分享方需要先拉起应用选择框并将要分享的数据传递给被分享方应用。因此,在分享方的代码中需要嵌套使用两层Want。在第一层中,使用隐式Want和`ohos.want.action.select`的action来启动应用选择框。在第二层Want中,声明要传递给被分享方应用的数据。
为了实现数据分享功能,分享方需要先拉起应用分享框并将要分享的数据传递给被分享方应用。因此,在分享方的代码中需要嵌套使用两层Want。在第一层中,使用隐式Want和`ohos.want.action.select`的action来启动应用分享框。在第二层Want中,声明要传递给被分享方应用的数据。
具体来说,可以将要分享的数据放在自定义字段`parameters`中,然后将包含`ohos.want.action.sendData`的action和`parameters`字段的Want作为第二层Want传递给应用选择框。被分享方应用可以通过获取参数`parameters`来获取分享的数据。
具体来说,可以将要分享的数据放在自定义字段`parameters`中,然后将包含`ohos.want.action.sendData`的action和`parameters`字段的Want作为第二层Want传递给应用分享框。被分享方应用可以通过获取参数`parameters`来获取分享的数据。
```ts
import common from '@ohos.app.ability.common';
......@@ -34,15 +34,15 @@ function implicitStartAbility() {
// which is intended to add info to application selector.
parameters: {
// The MIME type of pdf
"ability.picker.type": fileType,
"ability.picker.fileNames": [fileName],
"ability.picker.fileSizes": [fileSize],
'ability.picker.type': fileType,
'ability.picker.fileNames': [fileName],
'ability.picker.fileSizes': [fileSize],
// This a nested want which will be directly send to the user selected application.
"ability.want.params.INTENT": {
"action": "ohos.want.action.sendData",
"type": "application/pdf",
"parameters": {
"keyFd": { "type": "FD", "value": fileFd }
'ability.want.params.INTENT': {
'action': 'ohos.want.action.sendData',
'type': 'application/pdf',
'parameters': {
'keyFd': { 'type': 'FD', 'value': fileFd }
}
}
}
......
......@@ -31,6 +31,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
1. 在EntryAbility中,通过调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法启动UIAbility,[want](../reference/apis/js-apis-app-ability-want.md)为UIAbility实例启动的入口参数,其中bundleName为待启动应用的Bundle名称,abilityName为待启动的Ability名称,moduleName在待启动的UIAbility属于不同的Module时添加,parameters为自定义信息参数。示例中的context的获取方式请参见[获取UIAbility的上下文信息](uiability-usage.md#获取uiability的上下文信息)
```ts
let context = ...; // UIAbilityContext
let wantInfo = {
deviceId: '', // deviceId为空表示本设备
bundleName: 'com.example.myapplication',
......@@ -41,14 +42,14 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
},
}
// context为调用方UIAbility的UIAbilityContext
this.context.startAbility(wantInfo).then(() => {
context.startAbility(wantInfo).then(() => {
// ...
}).catch((err) => {
// ...
})
```
2. 在FuncAbility的生命周期回调文件中接收EntryAbility传递过来的参数。
2. 在FuncAbility的[onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate)或者[onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonnewwant)生命周期回调文件中接收EntryAbility传递过来的参数。
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
......@@ -64,11 +65,17 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
}
```
> **说明:**
>
> 在被拉起的FuncAbility中,可以通过获取传递过来的`want`参数的`parameters`来获取拉起方UIAbility的PID、Bundle Name等信息。
3. 在FuncAbility业务完成之后,如需要停止当前UIAbility实例,在FuncAbility中通过调用[terminateSelf()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateself)方法实现。
```ts
let context = ...; // UIAbilityContext
// context为需要停止的UIAbility实例的AbilityContext
this.context.terminateSelf((err) => {
context.terminateSelf((err) => {
// ...
});
```
......@@ -87,6 +94,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
1. 在EntryAbility中,调用[startAbilityForResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult)接口启动FuncAbility,异步回调中的data用于接收FuncAbility停止自身后返回给EntryAbility的信息。示例中的context的获取方式请参见[获取UIAbility的上下文信息](uiability-usage.md#获取uiability的上下文信息)
```ts
let context = ...; // UIAbilityContext
let wantInfo = {
deviceId: '', // deviceId为空表示本设备
bundleName: 'com.example.myapplication',
......@@ -97,7 +105,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
},
}
// context为调用方UIAbility的UIAbilityContext
this.context.startAbilityForResult(wantInfo).then((data) => {
context.startAbilityForResult(wantInfo).then((data) => {
// ...
}).catch((err) => {
// ...
......@@ -107,6 +115,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
2. 在FuncAbility停止自身时,需要调用[terminateSelfWithResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult)方法,入参abilityResult为FuncAbility需要返回给EntryAbility的信息。
```ts
let context = ...; // UIAbilityContext
const RESULT_CODE: number = 1001;
let abilityResult = {
resultCode: RESULT_CODE,
......@@ -120,7 +129,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
},
}
// context为被调用方UIAbility的AbilityContext
this.context.terminateSelfWithResult(abilityResult, (err) => {
context.terminateSelfWithResult(abilityResult, (err) => {
// ...
});
```
......@@ -128,12 +137,13 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
3. FuncAbility停止自身后,EntryAbility通过[startAbilityForResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult)方法回调接收被FuncAbility返回的信息,RESULT_CODE需要与前面的数值保持一致。
```ts
let context = ...; // UIAbilityContext
const RESULT_CODE: number = 1001;
// ...
// context为调用方UIAbility的UIAbilityContext
this.context.startAbilityForResult(want).then((data) => {
context.startAbilityForResult(wantInfo).then((data) => {
if (data?.resultCode === RESULT_CODE) {
// 解析被调用方UIAbility返回的信息
let info = data.want?.parameters?.info;
......@@ -186,6 +196,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
2. 在调用方want参数中的entities和action需要被包含在待匹配UIAbility的skills配置的entities和actions中。系统匹配到符合entities和actions参数条件的UIAbility后,会弹出选择框展示匹配到的UIAbility实例列表供用户选择使用。示例中的context的获取方式请参见[获取UIAbility的上下文信息](uiability-usage.md#获取uiability的上下文信息)
```ts
let context = ...; // UIAbilityContext
let wantInfo = {
deviceId: '', // deviceId为空表示本设备
// uncomment line below if wish to implicitly query only in the specific bundle.
......@@ -196,7 +207,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
}
// context为调用方UIAbility的UIAbilityContext
this.context.startAbility(wantInfo).then(() => {
context.startAbility(wantInfo).then(() => {
// ...
}).catch((err) => {
// ...
......@@ -209,8 +220,10 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
3. 在文档应用使用完成之后,如需要停止当前UIAbility实例,通过调用[terminateSelf()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateself)方法实现。
```ts
let context = ...; // UIAbilityContext
// context为需要停止的UIAbility实例的AbilityContext
this.context.terminateSelf((err) => {
context.terminateSelf((err) => {
// ...
});
```
......@@ -249,6 +262,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
2. 调用方使用[startAbilityForResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult)方法启动支付应用的UIAbility,在调用方want参数中的entities和action需要被包含在待匹配UIAbility的skills配置的entities和actions中。异步回调中的data用于后续接收支付UIAbility停止自身后返回给调用方的信息。系统匹配到符合entities和actions参数条件的UIAbility后,会弹出选择框展示匹配到的UIAbility实例列表供用户选择使用。
```ts
let context = ...; // UIAbilityContext
let wantInfo = {
deviceId: '', // deviceId为空表示本设备
// uncomment line below if wish to implicitly query only in the specific bundle.
......@@ -259,7 +273,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
}
// context为调用方UIAbility的UIAbilityContext
this.context.startAbilityForResult(wantInfo).then((data) => {
context.startAbilityForResult(wantInfo).then((data) => {
// ...
}).catch((err) => {
// ...
......@@ -269,6 +283,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
3. 在支付UIAbility完成支付之后,需要调用[terminateSelfWithResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult)方法实现停止自身,并将abilityResult参数信息返回给调用方。
```ts
let context = ...; // UIAbilityContext
const RESULT_CODE: number = 1001;
let abilityResult = {
resultCode: RESULT_CODE,
......@@ -282,7 +297,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
},
}
// context为被调用方UIAbility的AbilityContext
this.context.terminateSelfWithResult(abilityResult, (err) => {
context.terminateSelfWithResult(abilityResult, (err) => {
// ...
});
```
......@@ -290,6 +305,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
4. 在调用方[startAbilityForResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult)方法回调中接收支付应用返回的信息,RESULT_CODE需要与前面[terminateSelfWithResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult)返回的数值保持一致。
```ts
let context = ...; // UIAbilityContext
const RESULT_CODE: number = 1001;
let want = {
......@@ -297,7 +313,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
};
// context为调用方UIAbility的UIAbilityContext
this.context.startAbilityForResult(want).then((data) => {
context.startAbilityForResult(want).then((data) => {
if (data?.resultCode === RESULT_CODE) {
// 解析被调用方UIAbility返回的信息
let payResult = data.want?.parameters?.payResult;
......@@ -335,6 +351,7 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳
```ts
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
let context = ...; // UIAbilityContext
let wantInfo = {
deviceId: '', // deviceId为空表示本设备
bundleName: 'com.example.myapplication',
......@@ -348,7 +365,7 @@ let options = {
windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FLOATING
}
// context为调用方UIAbility的UIAbilityContext
this.context.startAbility(wantInfo, options).then(() => {
context.startAbility(wantInfo, options).then(() => {
// ...
}).catch((err) => {
// ...
......@@ -369,6 +386,7 @@ this.context.startAbility(wantInfo, options).then(() => {
```ts
let context = ...; // UIAbilityContext
let wantInfo = {
deviceId: '', // deviceId为空表示本设备
bundleName: 'com.example.myapplication',
......@@ -379,7 +397,7 @@ let wantInfo = {
},
}
// context为调用方UIAbility的UIAbilityContext
this.context.startAbility(wantInfo).then(() => {
context.startAbility(wantInfo).then(() => {
// ...
}).catch((err) => {
// ...
......@@ -468,12 +486,12 @@ export default class FuncAbility extends UIAbility {
```
> **说明:**
> 当被调用方[Ability的启动模式](uiability-launch-type.md)设置为standard启动模式时,每次启动都会创建一个新的实例,那么[onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)回调就不会被用到。
> 当被调用方[UIAbility组件启动模式](uiability-launch-type.md)设置为standard启动模式时,每次启动都会创建一个新的实例,那么[onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)回调就不会被用到。
## 通过Call调用实现UIAbility交互(仅对系统应用开放)
Call调用是UIAbility能力的扩展,它为UIAbility提供一种能够被外部调用并与外部进行通信的能力。Call调用支持前台与后台两种启动方式,使UIAbility既能被拉起到前台展示UI,也可以在后台被创建并运行。Call调用在调用方与被调用方间建立了IPC通信,因此应用开发者可通过Call调用实现不同Ability之间的数据共享。
Call调用是UIAbility能力的扩展,它为UIAbility提供一种能够被外部调用并与外部进行通信的能力。Call调用支持前台与后台两种启动方式,使UIAbility既能被拉起到前台展示UI,也可以在后台被创建并运行。Call调用在调用方与被调用方间建立了IPC通信,因此应用开发者可通过Call调用实现不同UIAbility之间的数据共享。
Call调用的核心接口是startAbilityByCall方法,与startAbility接口的不同之处在于:
......@@ -541,32 +559,14 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe
在Callee被调用端,需要实现指定方法的数据接收回调函数、数据的序列化及反序列化方法。在需要接收数据期间,通过on接口注册监听,无需接收数据时通过off接口解除监听。
1. 配置Ability的启动模式。
配置module.json5,将CalleeAbility配置为单实例"singleton"。
| Json字段 | 字段说明 |
| -------- | -------- |
| "launchType" | Ability的启动模式,设置为"singleton"类型。 |
Ability配置标签示例如下:
1. 配置UIAbility的启动模式。
```json
"abilities":[{
"name": ".CalleeAbility",
"srcEntrance": "./ets/CalleeAbility/CalleeAbility.ts",
"launchType": "singleton",
"description": "$string:CalleeAbility_desc",
"icon": "$media:icon",
"label": "$string:CalleeAbility_label",
"visible": true
}]
```
例如将CalleeAbility配置为单实例模式`singleton`,配置方式请参见[UIAbility组件启动模式](uiability-launch-type.md)
2. 导入UIAbility模块。
```ts
import Ability from '@ohos.app.ability.UIAbility';
import UIAbility from '@ohos.app.ability.UIAbility';
```
3. 定义约定的序列化数据。
......@@ -575,30 +575,30 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe
```ts
export default class MyParcelable {
num: number = 0
str: string = ""
num: number = 0;
str: string = '';
constructor(num, string) {
this.num = num
this.str = string
this.num = num;
this.str = string;
}
marshalling(messageSequence) {
messageSequence.writeInt(this.num)
messageSequence.writeString(this.str)
messageSequence.writeInt(this.num);
messageSequence.writeString(this.str);
return true
}
unmarshalling(messageSequence) {
this.num = messageSequence.readInt()
this.str = messageSequence.readString()
return true
this.num = messageSequence.readInt();
this.str = messageSequence.readString();
return true;
}
}
```
4. 实现Callee.on监听及Callee.off解除监听。
被调用端Callee的监听函数注册时机,取决于应用开发者。注册监听之前的数据不会被处理,取消监听之后的数据不会被处理。如下示例在Ability的onCreate注册'MSG_SEND_METHOD'监听,在onDestroy取消监听,收到序列化数据后作相应处理并返回,应用开发者根据实际需要做相应处理。具体示例代码如下:
被调用端Callee的监听函数注册时机,取决于应用开发者。注册监听之前的数据不会被处理,取消监听之后的数据不会被处理。如下示例在UIAbility的onCreate注册'MSG_SEND_METHOD'监听,在onDestroy取消监听,收到序列化数据后作相应处理并返回,应用开发者根据实际需要做相应处理。具体示例代码如下:
```ts
......@@ -618,7 +618,7 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe
return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`);
}
export default class CalleeAbility extends Ability {
export default class CalleeAbility extends UIAbility {
onCreate(want, launchParam) {
try {
this.callee.on(MSG_SEND_METHOD, sendMsgCallback);
......@@ -643,18 +643,18 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe
1. 导入UIAbility模块。
```ts
import Ability from '@ohos.app.ability.UIAbility';
import UIAbility from '@ohos.app.ability.UIAbility';
```
2. 获取Caller通信接口。
Ability的context属性实现了startAbilityByCall方法,用于获取指定通用组件的Caller通信接口。如下示例通过this.context获取Ability实例的context属性,使用startAbilityByCall拉起Callee被调用端并获取Caller通信接口,注册Caller的onRelease监听。应用开发者根据实际需要做相应处理。
UIAbilityContext属性实现了startAbilityByCall方法,用于获取指定通用组件的Caller通信接口。如下示例通过this.context获取UIAbility实例的context属性,使用startAbilityByCall拉起Callee被调用端并获取Caller通信接口,注册Caller的onRelease监听。应用开发者根据实际需要做相应处理。
```ts
// 注册caller的release监听
private regOnRelease(caller) {
try {
caller.on("release", (msg) => {
caller.on('release', (msg) => {
console.info(`caller onRelease is called ${msg}`);
})
console.info('caller register OnRelease succeed');
......
......@@ -237,7 +237,7 @@
- [@ohos.file.environment (目录环境能力)](js-apis-file-environment.md)
- [@ohos.file.fileAccess (公共文件访问与管理)](js-apis-fileAccess.md)
- [@ohos.file.fileExtensionInfo (公共文件访问与管理属性信息)](js-apis-fileExtensionInfo.md)
- [@ohos.file.fileUri (文件URI)](js-apis-file-fileUri.md)
- [@ohos.file.fileuri (文件URI)](js-apis-file-fileuri.md)
- [@ohos.file.fs (文件管理)](js-apis-file-fs.md)
- [@ohos.file.hash (文件哈希处理)](js-apis-file-hash.md)
- [@ohos.file.picker (选择器)](js-apis-file-picker.md)
......
......@@ -26,7 +26,7 @@ import Want from '@ohos.app.ability.Want';
| entities | Array\<string> | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器)。在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。 |
| uri | string | 否 | 表示携带的数据,一般配合type使用,指明待处理的数据类型。如果在Want中指定了uri,则Want将匹配指定的Uri信息,包括`scheme``schemeSpecificPart``authority``path`信息。 |
| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:'text/xml' 、 'image/*'等,MIME定义请参见https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 |
| parameters | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br />- ohos.aafwk.callerPid:表示拉起方的pid。<br />- ohos.aafwk.param.callerToken:表示拉起方的token。<br />- ohos.aafwk.param.callerUid:表示[BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。<br />- component.startup.newRules:表示是否启用新的管控规则。<br />- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。<br />- ohos.dlp.params.sandbox:表示dlp文件才会有。 |
| parameters | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br />- ohos.aafwk.callerPid:表示拉起方的pid。<br />- ohos.aafwk.param.callerBundleName:表示拉起方的Bundle Name。<br />- ohos.aafwk.param.callerToken:表示拉起方的token。<br />- ohos.aafwk.param.callerUid:表示[BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。<br />- component.startup.newRules:表示是否启用新的管控规则。<br />- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。<br />- ohos.dlp.params.sandbox:表示dlp文件才会有。 |
| [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | 否 | 表示处理Want的方式。默认传数字。<br />例如通过wantConstant.Flags.FLAG_ABILITY_CONTINUATION表示是否以设备间迁移方式启动Ability。 |
**示例:**
......@@ -34,6 +34,7 @@ import Want from '@ohos.app.ability.Want';
- 基础用法:在UIAbility对象中调用,示例中的context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)
```ts
let context = ...; // UIAbilityContext
let want = {
'deviceId': '', // deviceId为空表示本设备
'bundleName': 'com.example.myapplication',
......@@ -41,16 +42,17 @@ import Want from '@ohos.app.ability.Want';
'moduleName': 'entry' // moduleName非必选
};
this.context.startAbility(want, (err) => {
context.startAbility(want, (err) => {
// 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
- 通过自定字段传递数据,以下为当前支持类型(在UIAbility对象中调用,示例中的context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)
- 目前支持的数据类型有:字符串、数字、布尔、对象、数组和文件描述符等
* 字符串(String)
```ts
let context = ...; // UIAbilityContext
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
......@@ -59,12 +61,13 @@ import Want from '@ohos.app.ability.Want';
},
};
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
* 数字(Number)
```ts
let context = ...; // UIAbilityContext
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
......@@ -74,12 +77,13 @@ import Want from '@ohos.app.ability.Want';
},
};
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
* 布尔(Boolean)
```ts
let context = ...; // UIAbilityContext
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
......@@ -88,12 +92,13 @@ import Want from '@ohos.app.ability.Want';
},
};
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
* 对象(Object)
```ts
let context = ...; // UIAbilityContext
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
......@@ -107,12 +112,13 @@ import Want from '@ohos.app.ability.Want';
},
};
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
* 数组(Array)
```ts
let context = ...; // UIAbilityContext
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
......@@ -124,19 +130,21 @@ import Want from '@ohos.app.ability.Want';
},
};
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
* 文件描述符(FD)
```ts
import fs from '@ohos.file.fs';
let context = ...; // UIAbilityContext
let fd;
try {
fd = fs.openSync('/data/storage/el2/base/haps/pic.png').fd;
} catch(e) {
console.error('openSync fail: ${JSON.stringify(e)}');
} catch(err) {
console.error(`Failed to openSync. Code: ${err.code}, message: ${err.message}`);
}
let want = {
'deviceId': '', // deviceId为空表示本设备
......@@ -148,8 +156,7 @@ import Want from '@ohos.app.ability.Want';
}
};
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
......@@ -5044,7 +5044,7 @@ on(type: 'audioInterrupt', callback: Callback\<InterruptEvent>): void
监听音频中断事件。使用callback获取中断事件。
[on('interrupt')](#oninterruptdeprecated)一致,该接口在AudioRenderer对象start、pause、stop等事件发生前已经主动获取焦点,不需要开发者主动发起焦点申请。
[on('interrupt')](#oninterruptdeprecated)一致,均用于监听焦点变化。AudioRenderer对象在start事件发生时会主动获取焦点,在pause、stop等事件发生时会主动释放焦点,不需要开发者主动发起获取焦点或释放焦点的申请。
**系统能力:** SystemCapability.Multimedia.Audio.Interrupt
......@@ -5052,8 +5052,8 @@ on(type: 'audioInterrupt', callback: Callback\<InterruptEvent>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 事件回调类型,支持的事件为:'audioInterrupt'(中断事件被触发,音频播放被中断。) |
| callback | Callback<[InterruptEvent](#interruptevent9)> | 是 | 被监听的中断事件的回调。 |
| type | string | 是 | 事件回调类型,支持的事件为:'audioInterrupt'(中断事件被触发,音频渲染被中断。) |
| callback | Callback\<[InterruptEvent](#interruptevent9)\> | 是 | 被监听的中断事件的回调。 |
**错误码:**
......@@ -5066,50 +5066,68 @@ on(type: 'audioInterrupt', callback: Callback\<InterruptEvent>): void
**示例:**
```js
let isPlay;
let started;
let isPlaying; // 标识符,表示是否正在渲染
let isDucked; // 标识符,表示是否被降低音量
onAudioInterrupt();
async function onAudioInterrupt(){
audioRenderer.on('audioInterrupt', async(interruptEvent) => {
if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
// 由系统进行操作,强制打断音频渲染,应用需更新自身状态及显示内容等
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
console.info('Force paused. Stop writing');
isPlay = false;
// 音频流已被暂停,临时失去焦点,待可重获焦点时会收到resume对应的interruptEvent
console.info('Force paused. Update playing status and stop writing');
isPlaying = false; // 简化处理,代表应用切换至暂停状态的若干操作
break;
case audio.InterruptHint.INTERRUPT_HINT_STOP:
console.info('Force stopped. Stop writing');
isPlay = false;
// 音频流已被停止,永久失去焦点,若想恢复渲染,需用户主动触发
console.info('Force stopped. Update playing status and stop writing');
isPlaying = false; // 简化处理,代表应用切换至暂停状态的若干操作
break;
case audio.InterruptHint.INTERRUPT_HINT_DUCK:
// 音频流已被降低音量渲染
console.info('Force ducked. Update volume status');
isDucked = true; // 简化处理,代表应用更新音量状态的若干操作
break;
case audio.InterruptHint.INTERRUPT_HINT_UNDUCK:
// 音频流已被恢复正常音量渲染
console.info('Force ducked. Update volume status');
isDucked = false; // 简化处理,代表应用更新音量状态的若干操作
break;
default:
console.info('Invalid interruptEvent');
break;
}
} else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
// 由应用进行操作,应用可以自主选择打断或忽略
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_RESUME:
// 建议应用继续渲染(说明音频流此前被强制暂停,临时失去焦点,现在可以恢复渲染)
console.info('Resume force paused renderer or ignore');
await audioRenderer.start().then(async function () {
console.info('AudioInterruptMusic: renderInstant started :SUCCESS ');
started = true;
}).catch((err) => {
console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err}`);
started = false;
});
if (started) {
isPlay = true;
console.info(`AudioInterruptMusic Renderer started : isPlay : ${isPlay}`);
} else {
console.error('AudioInterruptMusic Renderer start failed');
}
// 若选择继续渲染,需在此处主动执行开始渲染的若干操作
break;
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
// 建议应用暂停渲染
console.info('Choose to pause or ignore');
if (isPlay == true) {
isPlay == false;
console.info('AudioInterruptMusic: Media PAUSE : TRUE');
} else {
isPlay = true;
console.info('AudioInterruptMusic: Media PLAY : TRUE');
}
// 若选择暂停渲染,需在此处主动执行暂停渲染的若干操作
break;
case audio.InterruptHint.INTERRUPT_HINT_STOP:
// 建议应用停止渲染
console.info('Choose to stop or ignore');
// 若选择停止渲染,需在此处主动执行停止渲染的若干操作
break;
case audio.InterruptHint.INTERRUPT_HINT_DUCK:
// 建议应用降低音量渲染
console.info('Choose to duck or ignore');
// 若选择降低音量渲染,需在此处主动执行降低音量渲染的若干操作
break;
case audio.InterruptHint.INTERRUPT_HINT_UNDUCK:
// 建议应用恢复正常音量渲染
console.info('Choose to unduck or ignore');
// 若选择恢复正常音量渲染,需在此处主动执行恢复正常音量渲染的若干操作
break;
default:
break;
}
}
......@@ -5760,6 +5778,83 @@ audioCapturer.getBufferSize().then((data) => {
});
```
### on('audioInterrupt')<sup>10+</sup>
on(type: 'audioInterrupt', callback: Callback\<InterruptEvent>): void
监听音频中断事件。使用callback获取中断事件。
[on('interrupt')](#oninterruptdeprecated)一致,均用于监听焦点变化。AudioCapturer对象在start事件发生时会主动获取焦点,在pause、stop等事件发生时会主动释放焦点,不需要开发者主动发起获取焦点或释放焦点的申请。
**系统能力:** SystemCapability.Multimedia.Audio.Interrupt
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 事件回调类型,支持的事件为:'audioInterrupt'(中断事件被触发,音频采集被中断。) |
| callback | Callback\<[InterruptEvent](#interruptevent9)\> | 是 | 被监听的中断事件的回调。 |
**错误码:**
以下错误码的详细介绍请参见[音频错误码](../errorcodes/errorcode-audio.md)
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 6800101 | if input parameter value error |
**示例:**
```js
let isCapturing; // 标识符,表示是否正在采集
onAudioInterrupt();
async function onAudioInterrupt(){
audioCapturer.on('audioInterrupt', async(interruptEvent) => {
if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
// 由系统进行操作,强制打断音频采集,应用需更新自身状态及显示内容等
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
// 音频流已被暂停,临时失去焦点,待可重获焦点时会收到resume对应的interruptEvent
console.info('Force paused. Update capturing status and stop reading');
isCapturing = false; // 简化处理,代表应用切换至暂停状态的若干操作
break;
case audio.InterruptHint.INTERRUPT_HINT_STOP:
// 音频流已被停止,永久失去焦点,若想恢复采集,需用户主动触发
console.info('Force stopped. Update capturing status and stop reading');
isCapturing = false; // 简化处理,代表应用切换至暂停状态的若干操作
break;
default:
console.info('Invalid interruptEvent');
break;
}
} else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
// 由应用进行操作,应用可以自主选择打断或忽略
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_RESUME:
// 建议应用继续采集(说明音频流此前被强制暂停,临时失去焦点,现在可以恢复采集)
console.info('Resume force paused renderer or ignore');
// 若选择继续采集,需在此处主动执行开始采集的若干操作
break;
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
// 建议应用暂停采集
console.info('Choose to pause or ignore');
// 若选择暂停采集,需在此处主动执行暂停采集的若干操作
break;
case audio.InterruptHint.INTERRUPT_HINT_STOP:
// 建议应用停止采集
console.info('Choose to stop or ignore');
// 若选择停止采集,需在此处主动执行停止采集的若干操作
break;
default:
break;
}
}
});
}
```
### on('markReach')<sup>8+</sup>
on(type: "markReach", frame: number, callback: Callback&lt;number&gt;): void
......
# @ohos.file.fileUri (文件URI)
# @ohos.file.fileuri (文件URI)
该模块提供通过PATH获取文件统一资源标志符(Uniform Resource Identifier,URI),后续可通过使用[@ohos.file.fs](js-apis-file-fs.md)进行相关open、read、write等操作,实现文件分享。
......@@ -8,7 +8,7 @@
## 导入模块
```js
import fileUri from "@ohos.file.fileUri";
import fileuri from "@ohos.file.fileuri";
```
使用该功能模块前,需要先获取其应用沙箱路径,开发示例如下:
......@@ -56,5 +56,5 @@ getUriFromPath(path: string): string
```js
let filePath = pathDir + "test.txt";
let uri = fileUri.getUriFromPath(filePath);
let uri = fileuri.getUriFromPath(filePath);
```
......@@ -955,7 +955,7 @@ truncate(file: string|number, len?: number): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------------------- |
| file | string\|number | 是 | 文件的应用沙箱路径或已打开的文件描述符fd。 |
| len | number | 否 | 文件截断后的长度,以字节为单位。 |
| len | number | 否 | 文件截断后的长度,以字节为单位。默认为0。 |
**返回值:**
......@@ -989,7 +989,7 @@ truncate(file: string|number, len?: number, callback: AsyncCallback&lt;void&gt;)
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | -------------------------------- |
| file | string\|number | 是 | 文件的应用沙箱路径或已打开的文件描述符fd。 |
| len | number | 否 | 文件截断后的长度,以字节为单位。 |
| len | number | 否 | 文件截断后的长度,以字节为单位。默认为0。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,本调用无返回值。 |
**示例:**
......@@ -1020,7 +1020,7 @@ truncateSync(file: string|number, len?: number): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------------------- |
| file | string\|number | 是 | 文件的应用沙箱路径或已打开的文件描述符fd。 |
| len | number | 否 | 文件截断后的长度,以字节为单位。 |
| len | number | 否 | 文件截断后的长度,以字节为单位。默认为0。 |
**示例:**
......@@ -1575,7 +1575,7 @@ listFile(path: string, options?: {
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| path | string | 是 | 文件夹的应用沙箱路径。 |
| options | Object | 否 | 文件过滤选项。 |
| options | Object | 否 | 文件过滤选项。默认不进行过滤。 |
**options参数说明:**
......@@ -1628,7 +1628,7 @@ listFile(path: string, options?: {
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| path | string | 是 | 文件夹的应用沙箱路径。 |
| options | Object | 否 | 文件过滤选项。 |
| options | Object | 否 | 文件过滤选项。默认不进行过滤。 |
| callback | AsyncCallback&lt;string[]&gt; | 是 | 异步列出文件名数组之后的回调。 |
**options参数说明:**
......@@ -1679,7 +1679,7 @@ listFileSync(path: string, options?: {
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| path | string | 是 | 文件夹的应用沙箱路径。 |
| options | Object | 否 | 文件过滤选项。 |
| options | Object | 否 | 文件过滤选项。默认不进行过滤。 |
**options参数说明:**
......
......@@ -617,6 +617,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): void
```
## UploadConfig
上传任务的配置信息。
**需要权限**:ohos.permission.INTERNET
......@@ -631,6 +632,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): void
| data | Array&lt;[RequestData](#requestdata)&gt; | 是 | 请求的表单数据。 |
## TaskState<sup>9+</sup>
上传任务信息,[on('complete' | 'fail')<sup>9+</sup>](#oncomplete--fail9)[off('complete' | 'fail')<sup>9+</sup>](#offcomplete--fail9)接口的回调参数。
**需要权限**:ohos.permission.INTERNET
......@@ -643,6 +645,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): void
| message | string | 是 | 上传任务结果描述信息 |
## File
[UploadConfig](#uploadconfig)中的文件列表。
**需要权限**:ohos.permission.INTERNET
......@@ -657,6 +660,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): void
## RequestData
[UploadConfig](#uploadconfig)中的表单数据。
**需要权限**:ohos.permission.INTERNET
......@@ -1657,6 +1661,7 @@ resume(callback: AsyncCallback&lt;void&gt;): void
## DownloadConfig
下载任务的配置信息。
**需要权限**:ohos.permission.INTERNET
......@@ -1676,6 +1681,7 @@ resume(callback: AsyncCallback&lt;void&gt;): void
## DownloadInfo<sup>7+</sup>
下载任务信息,[query<sup>(deprecated)</sup>](#querydeprecated-1)接口的回调参数。
**需要权限**:ohos.permission.INTERNET
......@@ -1694,3 +1700,5 @@ resume(callback: AsyncCallback&lt;void&gt;): void
| downloadTotalBytes | number | 是 | 下载的文件的总大小(int&nbsp;bytes)。 |
| description | string | 是 | 待下载文件的描述信息。 |
| downloadedBytes | number | 是 | 实时下载大小(int&nbsp;&nbsp;bytes)。 |
<!--no_check-->
\ No newline at end of file
......@@ -81,7 +81,7 @@ import web_webview from '@ohos.web.webview'
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
msgPort: WebMessagePort[] = null;
msgPort: web_webview.WebMessagePort[] = null;
build() {
Column() {
......
......@@ -3099,6 +3099,42 @@ onAudioStateChanged(callback: (event: { playing: boolean }) => void)
}
```
### onFirstContentfulPaint<sup>10+</sup>
onFirstContentfulPaint(callback: (event?: { navigationStartTick: number, firstContentfulPaintMs: number }) => void)
设置网页首次内容绘制回调函数。
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| -----------------------| -------- | ----------------------------------- |
| navigationStartTick | number | navigation开始的时间,单位以微秒表示。|
| firstContentfulPaintMs | number | 从navigation开始第一次绘制内容的时间,单位是以毫秒表示。|
**示例:**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src:'www.example.com', controller: this.controller })
.onFirstContentfulPaint(event => {
console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" +
event.navigationStartTick + ", [firstContentfulPaintMs]:" +
event.firstContentfulPaintMs)
})
}
}
}
```
### onLoadIntercept<sup>10+</sup>
onLoadIntercept(callback: (event?: { data: WebResourceRequest }) => boolean)
......
......@@ -42,7 +42,7 @@
| builder | [CustomBuilder](ts-types.md#custombuilder8) | 是 | 提示气泡内容的构造器。 |
| placement | [Placement](ts-appendix-enums.md#placement8) | 否 | 气泡组件优先显示的位置,当前位置显示不下时,会自动调整位置。<br/>默认值:Placement.Bottom |
| popupColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 提示气泡的颜色。 |
| enableArrow | boolean | 否 | 是否显示箭头。<br/>从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度的两倍(64vp),则实际不会显示箭头。<br/>默认值:true |
| enableArrow | boolean | 否 | 是否显示箭头。<br/>从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,此时如果气泡高度小于箭头的宽度(32vp)与气泡圆角两倍(48vp)之和(80vp),则实际不会显示箭头。<br/>默认值:true |
| autoCancel | boolean | 否 | 页面有操作时,是否自动关闭气泡。<br/>默认值:true |
| onStateChange | (event:&nbsp;{&nbsp;isVisible:&nbsp;boolean&nbsp;})&nbsp;=&gt;&nbsp;void | 否 | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 |
| arrowOffset<sup>9+</sup> | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,数值为0表示箭头居最左侧,偏移量为箭头至最左侧的距离,默认居中。箭头在气泡左右侧时,偏移量为箭头至最上侧的距离,默认居中。如果显示在屏幕边缘,气泡会自动左右偏移,数值为0时箭头始终指向绑定组件。 |
......
......@@ -19,13 +19,13 @@
| 文件名称 | 描述 |
| -------- | -------- |
| [context.h](context_8h.md) | 提供了Context相关的接口,可以配置运行时信息。 |
| [data_type.h](data__type_8h.md) | 声明了张量的数据的类型。 |
| [format.h](format_8h.md) | 提供张量数据的排列格式。 |
| [model.h](model_8h.md) | 提供了模型相关接口,可以用于模型创建、模型推理等。 |
| [status.h](status_8h.md) | 提供了Mindspore Lite运行时的状态码。 |
| [tensor.h](tensor_8h.md) | 提供了张量相关的接口,可用于创建和修改张量信息。 |
| [types.h](types_8h.md) | 提供了MindSpore Lite支持的模型文件类型和设备类型。 |
| [context.h](context_8h.md) | 提供了Context相关的接口,可以配置运行时信息。<br>引用文件:\<mindspore/context.h> |
| [data_type.h](data__type_8h.md) | 声明了张量的数据的类型。<br>引用文件:\<mindspore/data_type.h> |
| [format.h](format_8h.md) | 提供张量数据的排列格式。<br>引用文件:\<mindspore/format.h> |
| [model.h](model_8h.md) | 提供了模型相关接口,可以用于模型创建、模型推理等。<br>引用文件:\<mindspore/model.h> |
| [status.h](status_8h.md) | 提供了Mindspore Lite运行时的状态码。<br>引用文件:\<mindspore/status.h> |
| [tensor.h](tensor_8h.md) | 提供了张量相关的接口,可用于创建和修改张量信息。<br>引用文件:\<mindspore/tensor.h> |
| [types.h](types_8h.md) | 提供了MindSpore Lite支持的模型文件类型和设备类型。<br>引用文件:\<mindspore/types.h> |
### 结构体
......
......@@ -20,8 +20,8 @@
| 文件名称 | 描述 |
| -------- | -------- |
| [neural_network_runtime.h](neural__network__runtime_8h.md) | Neural Network Runtime部件接口定义,AI推理框架通过Neural Network Runtime提供的Native接口,完成模型构造与编译,并在加速硬件上执行推理计算。 |
| [neural_network_runtime_type.h](neural__network__runtime__type_8h.md) | Neural Network Runtime定义的结构体和枚举值。 |
| [neural_network_runtime.h](neural__network__runtime_8h.md) | Neural Network Runtime部件接口定义,AI推理框架通过Neural Network Runtime提供的Native接口,完成模型构造与编译,并在加速硬件上执行推理计算。<br>引用文件:\<neural_network_runtime/neural_network_runtime.h> |
| [neural_network_runtime_type.h](neural__network__runtime__type_8h.md) | Neural Network Runtime定义的结构体和枚举值。<br>引用文件:\<neural_network_runtime/neural_network_runtime_type.h> |
### 结构体
......
......@@ -54,23 +54,23 @@
| 名称 | 描述 |
| -------- | -------- |
| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc) | const char \*<br/>AVC视频编解码器的MIME类型。|
| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac) | const char \*<br/>AAC音频编解码器的MIME类型。|
| [OH_ED_KEY_TIME_STAMP](_codec_base.md#oh_ed_key_time_stamp) | const char \*<br/>提供统一的surface Buffer附属数据的字符描述符。|
| [OH_ED_KEY_EOS](_codec_base.md#oh_ed_key_eos) | const char \* |
| [OH_MD_KEY_TRACK_TYPE](_codec_base.md#oh_md_key_track_type) | const char \*<br/>为媒体播放框架提供统一的字符描述符。|
| [OH_MD_KEY_CODEC_MIME](_codec_base.md#oh_md_key_codec_mime) | const char \* |
| [OH_MD_KEY_DURATION](_codec_base.md#oh_md_key_duration) | const char \* |
| [OH_MD_KEY_BITRATE](_codec_base.md#oh_md_key_bitrate) | const char \* |
| [OH_MD_KEY_MAX_INPUT_SIZE](_codec_base.md#oh_md_key_max_input_size) | const char \* |
| [OH_MD_KEY_WIDTH](_codec_base.md#oh_md_key_width) | const char \* |
| [OH_MD_KEY_HEIGHT](_codec_base.md#oh_md_key_height) | const char \* |
| [OH_MD_KEY_PIXEL_FORMAT](_codec_base.md#oh_md_key_pixel_format) | const char \* |
| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](_codec_base.md#oh_md_key_audio_sample_format) | const char \* |
| [OH_MD_KEY_FRAME_RATE](_codec_base.md#oh_md_key_frame_rate) | const char \* |
| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](_codec_base.md#oh_md_key_video_encode_bitrate_mode) | const char \* |
| [OH_MD_KEY_PROFILE](_codec_base.md#oh_md_key_profile) | const char \* |
| [OH_MD_KEY_AUD_CHANNEL_COUNT](_codec_base.md#oh_md_key_aud_channel_count) | const char \* |
| [OH_MD_KEY_AUD_SAMPLE_RATE](_codec_base.md#oh_md_key_aud_sample_rate) | const char \* |
| [OH_MD_KEY_I_FRAME_INTERVAL](_codec_base.md#oh_md_key_i_frame_interval) | const char \* |
| [OH_MD_KEY_ROTATION](_codec_base.md#oh_md_key_rotation) | const char \* |
| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc) | AVC视频编解码器的MIME类型。|
| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac) | AAC音频编解码器的MIME类型。|
| [OH_ED_KEY_TIME_STAMP](_codec_base.md#oh_ed_key_time_stamp) | 提供统一的surface Buffer附属数据的字符描述符。|
| [OH_ED_KEY_EOS](_codec_base.md#oh_ed_key_eos) | surface附属数据中结束流的字符描述符,值类型为bool。 |
| [OH_MD_KEY_TRACK_TYPE](_codec_base.md#oh_md_key_track_type) | 为媒体播放框架提供统一的字符描述符。|
| [OH_MD_KEY_CODEC_MIME](_codec_base.md#oh_md_key_codec_mime) | MIME类型的字符描述符,值类型为string。 |
| [OH_MD_KEY_DURATION](_codec_base.md#oh_md_key_duration) |duration的字符描述符,值类型为int64_t。|
| [OH_MD_KEY_BITRATE](_codec_base.md#oh_md_key_bitrate) | 比特率的字符描述符,值类型为uint32_t。 |
| [OH_MD_KEY_MAX_INPUT_SIZE](_codec_base.md#oh_md_key_max_input_size) | 最大输入尺寸的字符描述符,值类型为uint32_t。 |
| [OH_MD_KEY_WIDTH](_codec_base.md#oh_md_key_width) | 视频宽度的字符描述符,值类型为uint32_t。 |
| [OH_MD_KEY_HEIGHT](_codec_base.md#oh_md_key_height) | 视频高度的字符描述符,值类型为uint32_t。 |
| [OH_MD_KEY_PIXEL_FORMAT](_codec_base.md#oh_md_key_pixel_format) | 视频像素格式的字符描述符,值类型为int32_t,具体见[OH_AVPixelFormat](_core.md#oh_avpixelformat) |
| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](_codec_base.md#oh_md_key_audio_sample_format) | 音频采样格式的字符描述符,值类型为uint32_t。 |
| [OH_MD_KEY_FRAME_RATE](_codec_base.md#oh_md_key_frame_rate) | 视频帧率的字符描述符,值类型为double。|
| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](_codec_base.md#oh_md_key_video_encode_bitrate_mode) | 视频编码比特率模式的字符描述符,值类型为int32_t,具体见[OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode) |
| [OH_MD_KEY_PROFILE](_codec_base.md#oh_md_key_profile) | 音视频编码能力的字符描述符,值类型为int32_t,具体见[OH_AVCProfile](_codec_base.md#oh_avcprofile)[OH_AACProfile](_codec_base.md#oh_aacprofile) |
| [OH_MD_KEY_AUD_CHANNEL_COUNT](_codec_base.md#oh_md_key_aud_channel_count) | 音频声道数的字符描述符,值类型为uint32_t。 |
| [OH_MD_KEY_AUD_SAMPLE_RATE](_codec_base.md#oh_md_key_aud_sample_rate) | 音频采样率的字符描述符,值类型为uint32_t。 |
| [OH_MD_KEY_I_FRAME_INTERVAL](_codec_base.md#oh_md_key_i_frame_interval) | I帧间隔时长的字符描述符,值类型为int32_t,单位是毫秒。|
| [OH_MD_KEY_ROTATION](_codec_base.md#oh_md_key_rotation) | surface旋转角度的字符描述符,值类型为int32_t,限于{0, 90, 180, 270},默认值为0。 |
......@@ -20,9 +20,9 @@
| 文件名称 | 描述 |
| ---------------------------------------- | ------------------ |
| [raw_dir.h](raw__dir_8h.md) | 提供rawfile目录相关功能。 |
| [raw_file.h](raw__file_8h.md) | 提供rawfile文件相关功能。 |
| [raw_file_manager.h](raw__file__manager_8h.md) | 提供资源管理rawfile相关功能。 |
| [raw_dir.h](raw__dir_8h.md) | 提供rawfile目录相关功能。<br>引用文件:\<rawfile/raw_dir.h> |
| [raw_file.h](raw__file_8h.md) | 提供rawfile文件相关功能。<br>引用文件:\<rawfile/raw_file.h> |
| [raw_file_manager.h](raw__file__manager_8h.md) | 提供资源管理rawfile相关功能。<br>引用文件:\<rawfile/raw_file_manager.h> |
### 结构体
......
......@@ -129,12 +129,14 @@ function convertAsyKey() {
2. 调用convertKey方法,传入公钥二进制和私钥二进制(二者非必选项,可只传入其中一个),转换为KeyPair对象。
```javascript
import cryptoFramework from "@ohos.security.cryptoFramework"
function convertEccAsyKey() {
let pubKeyArray = new Uint8Array([48,89,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,66,0,4,83,96,142,9,86,214,126,106,247,233,92,125,4,128,138,105,246,162,215,71,81,58,202,121,26,105,211,55,130,45,236,143,55,16,248,75,167,160,167,106,2,152,243,44,68,66,0,167,99,92,235,215,159,239,28,106,124,171,34,145,124,174,57,92]);
let priKeyArray = new Uint8Array([48,49,2,1,1,4,32,115,56,137,35,207,0,60,191,90,61,136,105,210,16,27,4,171,57,10,61,123,40,189,28,34,207,236,22,45,223,10,189,160,10,6,8,42,134,72,206,61,3,1,7]);
let pubKeyBlob = { data: pubKeyArray };
let priKeyBlob = { data: priKeyArray };
let generator = cryptoFrameWork.createAsyKeyGenerator("ECC256");
let generator = cryptoFramework.createAsyKeyGenerator("ECC256");
generator.convertKey(pubKeyBlob, priKeyBlob, (error, data) => {
if (error) {
AlertDialog.show({message : "Convert keypair fail"});
......@@ -1287,41 +1289,51 @@ function LoopMdPromise(algName, loopSize) {
**开发步骤**
1. 生成ECC密钥。通过createAsyKeyGenerator接口创建AsyKeyGenerator对象,并生成ECC非对称密钥
2. 基于ECC密钥的私钥及公钥执行ECDH操作
1. 通过createKeyAgreement接口创建KeyAgreement对象,用于后续的密钥协商操作
2. 调用KeyAgreement对象提供的generateSecret方法,传入对端的ECC公钥对象,以及本地生成的ECC私钥对象
```javascript
import cryptoFramework from "@ohos.security.cryptoFramework"
let globalKeyPair;
let globalSelfPriKey;
let globalPeerPubKey;
function ecdhPromise() {
let peerPubKeyArray = new Uint8Array([48,89,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,66,0,4,83,96,142,9,86,214,126,106,247,233,92,125,4,128,138,105,246,162,215,71,81,58,202,121,26,105,211,55,130,45,236,143,55,16,248,75,167,160,167,106,2,152,243,44,68,66,0,167,99,92,235,215,159,239,28,106,124,171,34,145,124,174,57,92]);
let peerPubKeyBlob = { data: peerPubKeyArray };
let eccGenerator = cryptoFramework.createAsyKeyGenerator("ECC256");
let eccKeyAgreement = cryptoFramework.createKeyAgreement("ECC256");
let keyGenPromise = eccGenerator.generateKeyPair();
keyGenPromise.then( keyPair => {
globalKeyPair = keyPair;
return eccKeyAgreement.generateSecret(keyPair.priKey, keyPair.pubKey);
eccGenerator.convertKey(peerPubKeyBlob, null).then((peerKeyPair) => {
globalPeerPubKey = peerKeyPair.pubKey;
return eccGenerator.generateKeyPair();
}).then((keyPair) => {
globalSelfPriKey = keyPair.priKey;
return eccKeyAgreement.generateSecret(globalSelfPriKey, globalPeerPubKey);
}).then((secret) => {
console.info("ecdh output is " + secret.data);
console.info("ecdh promise output is " + secret.data);
}).catch((error) => {
console.error("ecdh error.");
});
}
function ecdhCallback() {
let peerPubKeyArray = new Uint8Array([48,89,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,66,0,4,83,96,142,9,86,214,126,106,247,233,92,125,4,128,138,105,246,162,215,71,81,58,202,121,26,105,211,55,130,45,236,143,55,16,248,75,167,160,167,106,2,152,243,44,68,66,0,167,99,92,235,215,159,239,28,106,124,171,34,145,124,174,57,92]);
let peerPubKeyBlob = { data: peerPubKeyArray };
let eccGenerator = cryptoFramework.createAsyKeyGenerator("ECC256");
let eccKeyAgreement = cryptoFramework.createKeyAgreement("ECC256");
eccGenerator.convertKey(peerPubKeyBlob, null, function (err, peerKeyPair) {
globalPeerPubKey = peerKeyPair.pubKey;
eccGenerator.generateKeyPair(function (err, keyPair) {
globalKeyPair = keyPair;
eccKeyAgreement.generateSecret(keyPair.priKey, keyPair.pubKey, function (err, secret) {
globalSelfPriKey = keyPair.priKey;
eccKeyAgreement.generateSecret(globalSelfPriKey, globalPeerPubKey, function (err, secret) {
if (err) {
console.error("ecdh error.");
return;
}
console.info("ecdh output is " + secret.data);
console.info("ecdh callback output is " + secret.data);
});
});
})
}
```
......
......@@ -50,7 +50,7 @@
| ECC/SHA1<br>ECC/SHA224 | 8+ | |否|
| ECC/SHA256<br>ECC/SHA384<br>ECC/SHA512 | 8+ | |是|
| ECC/NoDigest | 9+ |NoDigest 需要指定TAG HuksKeyDigest.HUKS_DIGEST_NONE |否|
| ED25519/NoDigest | 8+ | NoDigest 需要指定TAG HuksKeyDigest.HUKS_DIGEST_NONE ||
| ED25519/NoDigest | 8+ | NoDigest 需要指定TAG HuksKeyDigest.HUKS_DIGEST_NONE ||
| SM2/SM3|9+ | |是|
| SM2/NoDigest |9+ | |否|
......
......@@ -186,7 +186,7 @@ try{
try{
workScheduler.isLastWorkTimeOut(500, (error, res) =>{
if (error) {
onsole.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`);
console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`);
} else {
console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`);
}
......
......@@ -320,7 +320,6 @@ export default class EntryAbility extends UIAbility {
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import ExtensionContext from '@ohos.app.ability.ServiceExtensionAbility';
import window from '@ohos.window';
export default class EntryAbility extends UIAbility {
......
# OpenHarmony 1.0(2020-09-10)
# OpenHarmony 1.0(2020-09-10)(停止维护)
## 版本概述
......
# OpenHarmony 1.1.0 LTS(2021-04-01)
# OpenHarmony 1.1.0 LTS(2021-04-01)(停止维护)
## 版本概述
......
# OpenHarmony 1.1.1 LTS(2021-06-22)
# OpenHarmony 1.1.1 LTS(2021-06-22)(停止维护)
## 版本概述
......
# OpenHarmony v1.1.3 LTS
# OpenHarmony v1.1.3 LTS (停止维护)
## 版本概述
......
# OpenHarmony 1.1.4 LTS
# OpenHarmony 1.1.4 LTS (停止维护)
## 版本概述
......
# OpenHarmony v1.1.2 LTS
# OpenHarmony v1.1.2 LTS (停止维护)
## 版本概述
......
# OpenHarmony 1.1.5 LTS
# OpenHarmony 1.1.5 LTS (停止维护)
## 版本概述
......
......@@ -87,8 +87,8 @@ repo forall -c 'git lfs pull'
| Hi3516标准系统解决方案(二进制) | 3.1.2&nbsp;Release | [站点](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/standard_hi3516.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/standard_hi3516.tar.gz.sha256) |
| RK3568标准系统解决方案(二进制) | 3.1.2&nbsp;Release | [站点](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/standard_rk3568.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/standard_rk3568.tar.gz.sha256) |
| Hi3861轻量系统解决方案(二进制) | 3.1.2&nbsp;Release | [站点](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_pegasus.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_pegasus.tar.gz.sha256) |
| Hi3516轻量系统解决方案-LiteOS(二进制) | 3.1.2&nbsp;Release | [站点](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus.tar.gz.sha256) |
| Hi3516轻量系统解决方案-Linux(二进制) | 3.1.2&nbsp;Release | [站点](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus_linux.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus_linux.tar.gz.sha256) |
| Hi3516小型系统解决方案-LiteOS(二进制) | 3.1.2&nbsp;Release | [站点](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus.tar.gz.sha256) |
| Hi3516小型系统解决方案-Linux(二进制) | 3.1.2&nbsp;Release | [站点](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus_linux.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/hispark_taurus_linux.tar.gz.sha256) |
| 标准系统Full&nbsp;SDK包(Mac) | 3.1.7.5 | [站点](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-mac-full.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-mac-full.tar.gz.sha256) |
| 标准系统Full&nbsp;SDK包(Windows\Linux) | 3.1.7.5 | [站点](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-full.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-full.tar.gz.sha256) |
| 标准系统Public&nbsp;SDK包(Mac) | 3.1.7.5 | [站点](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-mac-public.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/harmonyos/os/3.1.2/ohos-sdk-mac-public.tar.gz.sha256) |
......
......@@ -77,7 +77,7 @@ repo forall -c 'git lfs pull'
| -------- | -------- | -------- | -------- |
| 全量代码(标准、轻量和小型系统) | 3.1.3&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/code-v3.1.3-Release.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/code-v3.1.3-Release.tar.gz.sha256) |
| Hi3516标准系统解决方案(二进制) | 3.1.3&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/standard_hi3516.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/standard_hi3516.tar.gz.sha256) |
| RK3568标准系统解决方案(二进制) | 3.1.3&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/code-v3.1.3-Release.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/standard_rk3568.tar.gz.sha256) |
| RK3568标准系统解决方案(二进制) | 3.1.3&nbsp;Release | [站点](https://mirrors.huaweicloud.com/harmonyos/os/3.1.3/standard_rk3568.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/standard_rk3568.tar.gz.sha256) |
| Hi3861轻量系统解决方案(二进制) | 3.1.3&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_pegasus.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_pegasus.tar.gz.sha256) |
| Hi3516小型系统解决方案-LiteOS(二进制) | 3.1.3&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus.tar.gz.sha256) |
| Hi3516小型系统解决方案-Linux(二进制) | 3.1.3&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus_linux.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus_linux.tar.gz.sha256) |
......
# OpenHarmony 3.1.7 Release
## 版本概述
当前版本在OpenHarmony 3.1.6 Release的基础上,修复了内存泄漏及linux kernel等开源组件的安全漏洞,增强了系统安全性。修复了部分系统稳定性的issue,增强了系统稳定性。更新配套的SDK版本。
## 配套关系
**表1** 版本软件和工具配套关系
| 软件 | 版本 | 备注 |
| ------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| OpenHarmony | 3.1.7&nbsp;Release | NA |
| Full&nbsp;SDK | Ohos_sdk_full&nbsp;3.1.13.5&nbsp;(API&nbsp;Version&nbsp;8&nbsp;Relese) | 面向OEM厂商提供,包含了需要使用系统权限的系统接口。<br/>使用Full&nbsp;SDK时需要手动从镜像站点获取,并在DevEco&nbsp;Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 |
| Public&nbsp;SDK | Ohos_sdk_public&nbsp;3.1.13.5&nbsp;(API&nbsp;Version&nbsp;8&nbsp;Release) | 面向应用开发者提供,不包含需要使用系统权限的系统接口。<br/>DevEco&nbsp;Studio&nbsp;3.0&nbsp;Beta4版本起,通过DevEco&nbsp;Studio获取的SDK默认为Public&nbsp;SDK。 |
| HUAWEI&nbsp;DevEco&nbsp;Studio(可选) | 3.1&nbsp;Preview&nbsp;for&nbsp;OpenHarmony | OpenHarmony应用开发推荐使用。 |
| HUAWEI&nbsp;DevEco&nbsp;Device&nbsp;Tool(可选) | 3.0&nbsp;Release | OpenHarmony智能设备集成开发环境推荐使用。 |
## 源码获取
### 前提条件
1. 注册码云gitee账号。
2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)
3. 安装[git客户端](https://gitee.com/link?target=https%3A%2F%2Fgit-scm.com%2Fbook%2Fzh%2Fv2%2F%25E8%25B5%25B7%25E6%25AD%25A5-%25E5%25AE%2589%25E8%25A3%2585-Git)[git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading)并配置用户信息。
```
git config --global user.name "yourname"
git config --global user.email "your-email-address"
git config --global credential.helper store
```
4. 安装码云repo工具,可以执行如下命令。
```
curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中chmod a+x /usr/local/bin/repo
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
```
### 通过repo获取
**方式一(推荐)**
通过repo + ssh 下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。
```
repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.1.7-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
**方式二**
通过repo + https 下载。
```
repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-v3.1.7-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
### 从镜像站点获取
**表2** 获取源码路径
| 版本源码 | **版本信息** | **下载站点** | **SHA256校验码** |
| ------------------------------------------ | ------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 全量代码(标准、轻量和小型系统) | 3.1.7&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/code-v3.1.7-Release.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/code-v3.1.7-Release.tar.gz.sha256) |
| Hi3516标准系统解决方案(二进制) | 3.1.7&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/standard_hi3516.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/standard_hi3516.tar.gz.sha256) |
| RK3568标准系统解决方案(二进制) | 3.1.7&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/standard_rk3568.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/standard_rk3568.tar.gz.sha256) |
| Hi3861轻量系统解决方案(二进制) | 3.1.7&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/hispark_pegasus.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/hispark_pegasus.tar.gz.sha256) |
| Hi3516小型系统解决方案-LiteOS(二进制) | 3.1.7&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/hispark_taurus.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/hispark_taurus.tar.gz.sha256) |
| Hi3516小型系统解决方案-Linux(二进制) | 3.1.7&nbsp;Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/hispark_taurus_linux.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/hispark_taurus_linux.tar.gz.sha256) |
| 标准系统Full&nbsp;SDK包(Mac) | 3.1.13.5 | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/ohos-sdk-mac-full.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/ohos-sdk-mac-full.tar.gz.sha256) |
| 标准系统Full&nbsp;SDK包(Windows\Linux) | 3.1.13.5 | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/ohos-sdk-full.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/ohos-sdk-full.tar.gz.sha256) |
| 标准系统Public&nbsp;SDK包(Mac) | 3.1.13.5 | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/ohos-sdk-mac-public.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/ohos-sdk-mac-public.tar.gz.sha256) |
| 标准系统Public&nbsp;SDK包(Windows\Linux) | 3.1.13.5 | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/ohos-sdk-public.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.1.7/ohos-sdk-public.tar.gz.sha256) |
## 更新说明
本版本在OpenHarmony 3.1.7 Release的基础上有如下变更。
### 特性变更
本次版本无新增特性及变更。
### API变更
3.1.7 Release对比3.1.6 Release API接口无变更。
### 芯片及开发板适配
芯片及开发板适配状态请参考[SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig-devboard/sig_devboard_cn.md)信息。
### 修复缺陷列表
**表3** 修复缺陷issue列表
| 子系统 | 问题描述 |
| ------------ | ------------------------------------------------------------ |
| 应用子系统 | 进入联系人页面时“无联系人”默认页面一闪而过,进入联系人列表([I5ET9R](https://gitee.com/openharmony/applications_contacts/issues/I5ET9R))<br/>新建卡片推包到rk版,将卡片添加到桌面,长按桌面卡片,弹出服务卡片和移除按钮的同时也打开了应用([I5YB1O](https://gitee.com/openharmony/applications_hap/issues/I5YB1O))<br/>通过工具测出CPPCrash问题([I65H83](https://gitee.com/openharmony/applications_permission_manager/issues/I65H83))<br/>通过工具测出CPPCrash问题([I65TVW](https://gitee.com/openharmony/applications_permission_manager/issues/I65TVW))<br/>Launcher 反复点击recent 按钮会出现内存泄漏([I67SRG](https://gitee.com/openharmony/xts_acts/issues/I67SRG)) |
| 媒体子系统 | 打开图库应用,选择相册页签,点击相机,高概率闪退值桌面([I5QUSZ](https://gitee.com/openharmony/applications_hap/issues/I5QUSZ))<br/>通过工具测出CPPCrash问题([I65GZ1](https://gitee.com/openharmony/multimedia_medialibrary_standard/issues/I65GZ1)) |
| 全球化子系统 | 通过工具测出CPPCrash问题([I65GR8](https://gitee.com/openharmony/global_resmgr_standard/issues/I65GR8)) |
| 无障碍子系统 | 安全注入攻击测试,测试报告中存在服务接口ohos.accessibility.IAccessibleAbilityManagerServiceClient存在注入异常([I65PHE](https://gitee.com/openharmony/accessibility/issues/I65PHE)) |
| ArkUI子系统 | 图像效果功能失效([I65UID](https://gitee.com/openharmony/arkui_ace_engine/issues/I65UID)) |
| 元能力子系统 | 两个窗口分屏配对后,关闭B窗口另一个窗口也会关闭([I6AF0Y](https://gitee.com/openharmony/ability_ability_runtime/issues/I6AF0Y)) |
| DFX子系统 | ohos.samples.distributedmusicplayer出现libhilog.z.so崩溃([I6DCSL](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I6DCSL)) |
### 修复安全漏洞列表
**表4** 修复安全问题列表
| ISSUE | 问题描述 | 修复链接 |
| ------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| I67XCL | 修复组件kernel_linux_5.10上的CVE-2022-3640安全漏洞 | [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/659) |
| I6A56Q | 修复组件kernel_linux_5.10上的CVE-2023-20928安全漏洞 | [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/653) |
| I6B0K7 | 修复组件kernel_linux_5.10上的CVE-2022-4696安全漏洞 | [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/663) |
| I6BNVW | 修复组件mbedtls上的CVE-2021-44732、CVE-2021-45450安全漏洞 | [PR](https://gitee.com/openharmony/third_party_mbedtls/pulls/78) |
| I6BTZM | 修复组件flutter上的CVE-2022-37434安全漏洞 | [PR](https://gitee.com/openharmony/third_party_flutter/pulls/247) |
| I6BXT0 | 修复组件kernel_linux_5.10上的CVE-2023-23559、CVE-2023-0179、CVE-2023-23454、CVE-2023-23455安全漏洞 | [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/661) |
| I6DQAH | 修复组件kernel_linux_5.10上的CVE-2023-0590、CVE-2022-3707安全漏洞 | [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/687) |
| I6DTV8 | 修复组件libexif上的CVE-2019-9278安全漏洞 | [PR](https://github.com/libexif/libexif/commit/75aa73267fdb1e0ebfbc00369e7312bac43d0566) |
| I6E5KA | 修复组件openssl上的CVE-2023-0286安全漏洞 | [PR](https://gitee.com/openharmony/third_party_openssl/pulls/83) |
| I6FFUV | 修复组件kernel_linux_5.10上的CVE-2023-20938、CVE-2023-0045、CVE-2023-0615安全漏洞 | [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/696) |
| I6FZ3A | 修复组件cares上的CVE-2022-4904安全漏洞 | [PR](https://gitee.com/openharmony/third_party_cares/pulls/12) |
| I6HYRO | 修复组件kernel_linux_4.19上的CVE-2022-3028安全漏洞 | [PR](https://gitee.com/openharmony/kernel_linux_4.19/pulls/98) |
| I6JH1I | 修复组件kernel_linux_5.10上的CVE-2023-0461、CVE-2023-23004、CVE-2023-23000、CVE-2023-1078、CVE-2023-1076、CVE-2023-1118、CVE-2023-22995、CVE-2023-26545安全漏洞 | [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/725) |
| I6JH1L | 修复组件kernel_linux_4.19上的CVE-2023-0461、CVE-2023-26545、CVE-2022-0480、CVE-2023-1118、CVE-2022-1652、CVE-2021-3760安全漏洞 | [PR](https://gitee.com/openharmony/kernel_linux_4.19/pulls/107) |
| I6JH2L | 修复组件kernel_linux_4.19上的CVE-2023-23559、CVE-2022-47929、CVE-2022-2873、CVE-2023-23455安全漏洞 | [PR](https://gitee.com/openharmony/kernel_linux_4.19/pulls/103) |
| I6LCHO | 修复组件kernel_linux_4.19上的CVE-2023-0030安全漏洞 | [PR](https://gitee.com/openharmony/kernel_linux_4.19/pulls/111) |
##
**表5** 遗留缺陷列表
| issue | 问题描述 | 影响 | 计划解决日期 |
| ------------------------------------------------------------ | -------------------------------------- | -------------- | ------------ |
| [I6HAUC](https://gitee.com/openharmony/xts_acts/issues/I6HAUC) | 【3.1】调用Windows接口横竖屏鼠标会变形 | 影响开发者体验 | 2023-04-28 |
\ No newline at end of file
......@@ -7,6 +7,8 @@
- [OpenHarmony v3.2 Beta2 (2022-07-30)](OpenHarmony-v3.2-beta2.md)
- [OpenHarmony v3.2 Beta1 (2022-05-31)](OpenHarmony-v3.2-beta1.md)
- [OpenHarmony v3.1 Release (2022-03-30)](OpenHarmony-v3.1-release.md)
- [OpenHarmony v3.1.6 Release (2023-01-30)](OpenHarmony-v3.1.6-release.md)
- [OpenHarmony v3.1.5 Release (2022-12-30)](OpenHarmony-v3.1.5-release.md)
- [OpenHarmony v3.1.4 Release (2022-11-02)](OpenHarmony-v3.1.4-release.md)
- [OpenHarmony v3.1.3 Release (2022-09-30)](OpenHarmony-v3.1.3-release.md)
- [OpenHarmony v3.1.2 Release (2022-08-24)](OpenHarmony-v3.1.2-release.md)
......@@ -25,7 +27,7 @@
- [OpenHarmony v2.2 beta2 (2021-08-04)](OpenHarmony-v2.2-beta2.md)
- [OpenHarmony 2.0 Canary (2021-06-01)](OpenHarmony-2-0-Canary.md)
## OpenHarmony 1.x Releases
## OpenHarmony 1.x Releases(停止维护)
- [OpenHarmony v1.0 (2020-09-10)](OpenHarmony-1-0.md)
- [OpenHarmony v1.1.5 LTS (2022-08-24)](OpenHarmony-v1.1.5-LTS.md)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册