diff --git a/en/application-dev/dfx/apprecovery-guidelines.md b/en/application-dev/dfx/apprecovery-guidelines.md index 4a82385816bd7f51ca0dadf85aff9961f84b94ca..cf31f6ae4c18f0de1e850cad5cb34be2122bc0d0 100644 --- a/en/application-dev/dfx/apprecovery-guidelines.md +++ b/en/application-dev/dfx/apprecovery-guidelines.md @@ -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 diff --git a/en/application-dev/dfx/figures/fault_rectification.png b/en/application-dev/dfx/figures/fault_rectification.png index e5831ac2b5aefc33a955ad98cd76f41ad28a7f70..a178b2691616d406d2668806ffcd4f89c8ca82a3 100644 Binary files a/en/application-dev/dfx/figures/fault_rectification.png and b/en/application-dev/dfx/figures/fault_rectification.png differ diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index b02b9397aea367ddedb856a78975382306db8c21..d4b34e125d2d723f1825aca53a801b1a729c5b9b 100644 --- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -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 => { }); ``` -### checkAccessTokenSync10+ - -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. ### PermissionStateChangeInfo9+ -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). | + diff --git a/en/application-dev/reference/apis/js-apis-file-storage-statistics.md b/en/application-dev/reference/apis/js-apis-file-storage-statistics.md index 834bf7bcbdd703786d9bb43db8fe0b61956fdd52..716e0da462bf4e59d0cd969deb561e0adc23a351 100644 --- a/en/application-dev/reference/apis/js-apis-file-storage-statistics.md +++ b/en/application-dev/reference/apis/js-apis-file-storage-statistics.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 ## BundleStats9+ -### 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. ## StorageStats9+ -### Attributes - **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics - -This is a system API. +**System API**: This is a system API. | Name | Type | Readable | Writable | Description | | --------- | ------ | ---- | ----- | -------------- | diff --git a/en/application-dev/reference/apis/js-apis-system-cipher.md b/en/application-dev/reference/apis/js-apis-system-cipher.md index b99f72e1fb59bd6af33a0bd5f7cc090fc6fc1222..30ac917b4c2ff2867cbbe4c54385500316494520 100644 --- a/en/application-dev/reference/apis/js-apis-system-cipher.md +++ b/en/application-dev/reference/apis/js-apis-system-cipher.md @@ -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 diff --git a/en/device-dev/subsystems/figures/call-chain-trace-in-synchronous-communication.png b/en/device-dev/subsystems/figures/call-chain-trace-in-synchronous-communication.png new file mode 100644 index 0000000000000000000000000000000000000000..585d8aac7b4857645b78ab11effbe900e5350f9d Binary files /dev/null and b/en/device-dev/subsystems/figures/call-chain-trace-in-synchronous-communication.png differ diff --git a/en/device-dev/subsystems/figures/process_crash_handling_flowchart.png b/en/device-dev/subsystems/figures/process_crash_handling_flowchart.png new file mode 100644 index 0000000000000000000000000000000000000000..65774b41cd4b6bc3c4f03c271fd0cefb9aec6d8d Binary files /dev/null and b/en/device-dev/subsystems/figures/process_crash_handling_flowchart.png differ diff --git a/en/device-dev/subsystems/subsys-dfx-faultlogger.md b/en/device-dev/subsystems/subsys-dfx-faultlogger.md index 209734174320846cc68004b82dfff89447df453b..21513ea9cf913eff37a626c7e74294e95fde69ed 100644 --- a/en/device-dev/subsystems/subsys-dfx-faultlogger.md +++ b/en/device-dev/subsystems/subsys-dfx-faultlogger.md @@ -4,108 +4,121 @@ ## 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| +| Scenario| Tool| Usage| | -------- | -------- | -------- | -| To understand the function call sequence| DumpCatcher 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| +| Class| API| Description| | -------- | -------- | -------- | -| DfxDumpCatcher | bool DumpCatch(const int pid, const int tid, std::string& msg) | Return value:
**true**: Back trace is successful. Related information is stored in the **msg** string object.
**false**: Back trace failed.
Input arguments:
**pid**: target process ID.
**tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.
Output argument:
**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& msg) | Return value:
- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.
- **false**: Dumping of stack information has failed.
Input arguments:
- **pid**: target process ID.
- **tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.
Output arguments:
- **msg**: If back trace is successful, call stack information is returned through **msg**.| +| DfxDumpCatcher | bool DumpCatchMix(const int pid, const int tid, std::string& msg) | Return value:
- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.
- **false**: Dumping of stack information has failed.
Input arguments:
**pid**: target process ID.
- **tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.
Output arguments:
- **msg**: If back trace is successful, hybrid stack information is returned through **msg**.| +| DfxDumpCatcher | bool DumpCatchFd(const int pid, const int tid, std::string& msg, int fd) | Return value:
- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.
- **false**: Dumping of stack information has failed.
Input arguments:
**pid**: target process ID.
- **tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.
- **fd**: handle of the file to be written.
Output parameters:
- **msg**: If back trace is successful, call stack information is returned through **msg**.| +| DfxDumpCatcher | bool DumpCatchMultiPid(const std::vector\ pidV, std::string& msg) | Return value:
- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.
- **false**: Dumping of stack information has failed.
Input arguments:
- **pidV**: target process ID list.
Output arguments:
- **msg**: If back trace is successful, call stack information is returned through **msg**.| -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
-> 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 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. -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. +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**. -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**. - ``` import("//base/hiviewdfx/faultloggerd/faultloggerd.gni") import("//build/ohos.gni") - + config("dumpcatcherdemo_config") { visibility = [ ":*" ] - + include_dirs = [ ".", "//utils/native/base/include", "//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher/include/", # Add the path of the dump_catcher header file. ] } - - 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" } ``` 2. Define the header file. Take **/base/hiviewdfx/faultloggerd/example/dump_catcher_demo.h** as an example. In the sample code, the function of the stack depth test is called to construct a call stack with a specified depth. - + ``` #ifndef DUMP_CATCHER_DEMO_H #define DUMP_CATCHER_DEMO_H - + #include - + #define NOINLINE __attribute__((noinline)) - + // Define the macro function to automatically generate a function call chain. #define GEN_TEST_FUNCTION(FuncNumA, FuncNumB) \ __attribute__((noinline)) int TestFunc##FuncNumA() \ { \ return TestFunc##FuncNumB(); \ } - + // Call the function of the stack depth test. int TestFunc0(void); int TestFunc1(void); @@ -118,33 +131,33 @@ You can use DumpCatcher to obtain the call stack of a specified process (thread) int TestFunc8(void); int TestFunc9(void); int TestFunc10(void); - + #endif // DUMP_CATCHER_DEMO_H ``` 3. Call the **DumpCatch** API in the source file. Take **/base/hiviewdfx/faultloggerd/example/dump_catcher_demo.cpp** as an example. Include the **dfx_dump_catcher.h** file, declare the **DfxDumpCatcher** object, use the macro function to construct a function call chain, call the **DumpCatch** method, and pass the required process ID and thread ID of the call stack into this method. - + ``` #include "dump_catcher_demo.h" - + #include #include #include // Include the dfx_dump_catcher.h file. #include "dfx_dump_catcher.h" using namespace std; - + NOINLINE int TestFunc10(void) { 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; } return 0; } - + // Use the macro function to automatically generate a function call chain. GEN_TEST_FUNCTION(0, 1) GEN_TEST_FUNCTION(1, 2) @@ -156,7 +169,7 @@ You can use DumpCatcher to obtain the call stack of a specified process (thread) GEN_TEST_FUNCTION(7, 8) GEN_TEST_FUNCTION(8, 9) GEN_TEST_FUNCTION(9, 10) - + int main(int argc, char *argv[]) { TestFunc0(); @@ -165,55 +178,57 @@ 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| +| Tool| Path| Command| Description| | -------- | -------- | -------- | -------- | -| processdump | /system/bin | - processdump -p [pid]
- processdump -p [pid] -t [tid] | **Arguments:**
**- -p [pid]**: prints stack information for all threads of the specified process.
**- -p [pid] -t [tid]**: prints information for the specified thread of the specified process.
**Return value:**
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]
- dumpcatcher -p [pid] -t [tid]
- dumpcatcher -m -p [pid]
- dumpcatcher -m -p [pid] -t [tid]
| **Description:**
- **-p [pid]**: prints all thread stack information of the specified process.
- **-p [pid] -t [tid]**: prints stack information for the specified thread of the specified process.
- **-m -p [pid]**: prints hybrid stack information for all threads of the specified process.
- **-m -p [pid] -t [tid]**: prints hybrid stack information for the specified thread of the specified process.
**Return value:**
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**
-> 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 +Print call stack information of the **hiview** process. -Use ProcessDump to print the call stack 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). - + ``` NOINLINE int TriggerSegmentFaultException() { @@ -228,40 +243,41 @@ You can locate faults based on the crash stack logs generated by FaultLoggerd. T 2. Obtain the crash function call stack log. The process generates a temporary log file in the** /data/log/faultlog/temp** directory due to an exception that is not handled. The naming rule of the temporary log file is as follows: - + ``` 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 ``` diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md index e6c0316c22cf0f0988f032218e92543c9f7b3acc..940b8188945ffdc01c6b35a44a27019339a69768 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md @@ -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.
Value:
1-100| | desc | Parameter description. This field is mandatory.
Rule:
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 diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-overview.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-overview.md index efd5de904fcdeed3d2467eb3c1b2f215e1ef4521..e1c5a61544b9413e3c36d46b86f5a789bad2e178 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-overview.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-overview.md @@ -1,4 +1,4 @@ -# HiSysEvent Overview +# HiSysEvent ## Introduction diff --git a/en/device-dev/subsystems/subsys-dfx-hitracechain.md b/en/device-dev/subsystems/subsys-dfx-hitracechain.md index 9b9b85b66a457a0653b12f7d450f13f7aaef2a4f..e58467e1ca4814649adfc40bad1f28be1b96f4d5 100644 --- a/en/device-dev/subsystems/subsys-dfx-hitracechain.md +++ b/en/device-dev/subsystems/subsys-dfx-hitracechain.md @@ -2,530 +2,237 @@ ## Overview -HiTraceChain tracks the call chain with the same **traceid** throughout the inter-device, inter-process, and inter-thread service processes. It associates and displays the call relationship and various output information during the entire process, helping you analyze and locate faults and optimize the system. +HiTraceChain tracks the call chain with the same **traceid** throughout the inter-device, inter-process, and inter-thread service processes. It associates and displays the call relationship and various output information during the entire process, helping you analyze and locate faults and optimize the system. -## Use Cases + +## When to Use HiTraceChain can be used for the following purposes: -- Associates and reports service process information \(such as logs and events\) on the device. +- Associates and reports service process information (such as logs and events) on the device. - Displays and analyzes reported information on the cloud to facilitate fault location. -- Works with the IDE to debug the detailed service process and time consumption distribution for system optimization. +- Works with the IDE to debug the detailed service process and time consumption distribution for system optimization. - **Figure 1** Use cases of HiTraceChain - + **Figure 1** Use cases of HiTraceChain ![](figures/use-cases-of-hitrace.png "use-cases-of-hitrace") ### Usage Example -**Figure 2** Service calling process \(inter-device and inter-process synchronous call\) + **Figure 2** Service calling process \(inter-device and inter-process synchronous call\) -![](figures/service-calling-process-(inter-device-and-inter-process-synchronous-call).png "service-calling-process-(inter-device-and-inter-process-synchronous-call)") + ![](figures/service-calling-process-(inter-device-and-inter-process-synchronous-call).png "service-calling-process-(inter-device-and-inter-process-synchronous-call)") 1. Display the call relationship in the service process, analyze key paths and function dependency, and determine the time consumption and call frequency at each call point to detect performance bottlenecks. - **Figure 3** Service calling process + **Figure 3** Service calling process + ![](figures/service-calling-process.png "service-calling-process") - ![](figures/service-calling-process.png "service-calling-process") - **Figure 4** Time delay in the service calling process + **Figure 4** Time delay in the service calling process + ![](figures/time-delay-in-the-service-calling-process.png "time-delay-in-the-service-calling-process") - ![](figures/time-delay-in-the-service-calling-process.png "time-delay-in-the-service-calling-process") +2. Add **traceid** to logs and events automatically to facilitate comprehensive analysis and quick fault location. -2. Add **traceid** to logs and events automatically to facilitate comprehensive analysis and quick fault location. ## Available APIs -HiTraceChain provides C++ and C APIs. The upper-layer services mainly use HiTraceChain to start and stop call chain tracing. +HiTraceChain provides C++ and C APIs. The upper-layer services mainly use HiTraceChain to start and stop call chain trace. + +HiTraceChain is implemented at layer C. It works by transferring **traceid** throughout the service calling process. Before service processing, HiTrace sets **traceid** in the thread local storage (TLS) of the calling thread. During service processing, HiTrace obtains **traceid** from the contextual TLS of the calling thread and automatically adds it to the log and event information. After service processing is complete, HiTrace clears **traceid** from the TLS of the calling thread. -HiTraceChain is implemented at layer C. It works by transferring **traceid** throughout the service calling process. Before service processing, HiTraceChain sets **traceid** in the thread local storage \(TLS\) of the calling thread. During service processing, HiTraceChain obtains **traceid** from the contextual TLS of the calling thread and automatically adds it to the log and event information. After service processing is complete, HiTraceChain clears **traceid** from the TLS of the calling thread. ### Java, C++, and C APIs -**Table 1** Description of C++ and C APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  

C++

-

C

-

Class

-

API

-

API

-

HiTraceChain

-

-

-

-

-

-

-

-

HiTraceId Begin(const std::string& name, int flags)

-

HiTraceIdStruct HiTraceChainBegin(const char* name, int flags)

-

void End(const HiTraceId& id)

-

void HiTraceChainEnd(const HiTraceIdStruct* pId)

-

HiTraceId GetId();

-

HiTraceIdStruct HiTraceChainGetId()

-

void SetId(const HiTraceId& id)

-

void HiTraceChainSetId(const HiTraceIdStruct* pId)

-

void ClearId()

-

void HiTraceChainClearId()

-

HiTraceId CreateSpan()

-

HiTraceIdStruct HiTraceChainCreateSpan()

-

void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...)

-

void HiTraceChainTracepoint(HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...)

-

void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...)

-

void HiTraceChainTracepointEx(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...)

-

HiTraceId

-

-

-

-

-

-

-

-

-

-

-

-

-

-

HiTraceId();

-

void HiTraceChainInitId(HiTraceIdStruct* pId)

-

HiTraceId(const uint8_t* pIdArray, int len)

-

HiTraceIdStruct HiTraceChainBytesToId(const uint8_t* pIdArray, int len)

-

bool IsValid()

-

int HiTraceChainIsValid(const HiTraceIdStruct* pId)

-

bool IsFlagEnabled(HiTraceFlag flag)

-

int HiTraceChainIsFlagEnabled(const HiTraceIdStruct* pId, HiTraceFlag flag)

-

void EnableFlag(HiTraceFlag flag)

-

void HiTraceChainEnableFlag(HiTraceIdStruct* pId, HiTraceFlag flag)

-

int GetFlags()

-

int HiTraceChainGetFlags(const HiTraceIdStruct* pId)

-

void SetFlags(int flags)

-

void HiTraceChainSetFlags(HiTraceIdStruct* pId, int flags)

-

uint64_t GetChainId()

-

uint64_t HiTraceChainGetChainId(const HiTraceIdStruct* pId)

-

void SetChainId(uint64_t chainId)

-

void HiTraceChainSetChainId(HiTraceIdStruct* pId, uint64_t chainId)

-

uint64_t GetSpanId()

-

uint64_t HiTraceChainGetSpanId(const HiTraceIdStruct* pId)

-

void SetSpanId(uint64_t spanId)

-

void HiTraceChainSetSpanId(HiTraceIdStruct* pId, uint64_t spanId)

-

uint64_t GetParentSpanId()

-

uint64_t HiTraceChainGetParentSpanId(const HiTraceIdStruct* pId)

-

void SetParentSpanId(uint64_t parentSpanId)

-

void HiTraceChainSetParentSpanId(HiTraceIdStruct* pId, uint64_t parentSpanId)

-

int ToBytes(uint8_t* pIdArray, int len)

-

int HiTraceChainIdToBytes(const HiTraceIdStruct* pId, uint8_t* pIdArray, int len)

-
+ **Table 1** Description of C++ and C APIs + +| | **C++** | **C** | +| -------- | -------- | -------- | +| **Class**| **Function**| **Function**| +| HiTraceChain | HiTraceId Begin(const std::string& name, int flags) | HiTraceIdStruct HiTraceChainBegin(const char* name, int flags) | +| | void End(const HiTraceId& id) | void HiTraceChainEnd(const HiTraceIdStruct* pId) | +| | HiTraceId GetId(); | HiTraceIdStruct HiTraceChainGetId() | +| | void SetId(const HiTraceId& id) | void HiTraceChainSetId(const HiTraceIdStruct* pId) | +| | void ClearId() | void HiTraceChainClearId() | +| | HiTraceId CreateSpan() | HiTraceIdStruct HiTraceChainCreateSpan() | +| | void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...) | void HiTraceChainTracepoint(HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...) | +| | void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...) | void HiTraceChainTracepointEx(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...) | +| HiTraceId | HiTraceId(); | void HiTraceChainInitId(HiTraceIdStruct* pId) | +| | HiTraceId(const uint8_t* pIdArray, int len) | HiTraceIdStruct HiTraceChainBytesToId(const uint8_t* pIdArray, int len) | +| | bool IsValid() | int HiTraceChainIsValid(const HiTraceIdStruct* pId) | +| | bool IsFlagEnabled(HiTraceFlag flag) | int HiTraceChainIsFlagEnabled(const HiTraceIdStruct* pId, HiTraceFlag flag) | +| | void EnableFlag(HiTraceFlag flag) | void HiTraceChainEnableFlag(HiTraceIdStruct* pId, HiTraceFlag flag) | +| | int GetFlags() | int HiTraceChainGetFlags(const HiTraceIdStruct* pId) | +| | void SetFlags(int flags) | void HiTraceChainSetFlags(HiTraceIdStruct* pId, int flags) | +| | uint64_t GetChainId() | uint64_t HiTraceChainGetChainId(const HiTraceIdStruct* pId) | +| | void SetChainId(uint64_t chainId) | void HiTraceChainSetChainId(HiTraceIdStruct* pId, uint64_t chainId) | +| | uint64_t GetSpanId() | uint64_t HiTraceChainGetSpanId(const HiTraceIdStruct* pId) | +| | void SetSpanId(uint64_t spanId) | void HiTraceChainSetSpanId(HiTraceIdStruct* pId, uint64_t spanId) | +| | uint64_t GetParentSpanId() | uint64_t HiTraceChainGetParentSpanId(const HiTraceIdStruct* pId) | +| | void SetParentSpanId(uint64_t parentSpanId) | void HiTraceChainSetParentSpanId(HiTraceIdStruct* pId, uint64_t parentSpanId) | +| | int ToBytes(uint8_t* pIdArray, int len) | int HiTraceChainIdToBytes(const HiTraceIdStruct_ pId, uint8_t* pIdArray, int len) | + ### Parameters of C++ APIs -**Table 2** Parameters of C++ APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Class

-

API

-

Description

-

HiTraceChain

-

-

-

-

-

-

-

-

HiTraceId Begin(const std::string& name, int flags)

-

Starts HiTraceChain, generates a HiTraceId object, and sets it in the TLS of the calling thread.

-

Input arguments:

-
  • name: Indicates the name of the service process.
  • flags: Indicates tracing flags, which can be used in combination.
    • HITRACE_FLAG_INCLUDE_ASYNC: Traces both synchronous and asynchronous calls. By default, only synchronous calls are traced.
    • HITRACE_FLAG_DONOT_CREATE_SPAN: Do not create a span. By default, a span is created.
    • HITRACE_FLAG_TP_INFO: Outputs the tracepoint information. By default, the information is not output.
    • HITRACE_FLAG_NO_BE_INFO: Do not output the start and end information. By default, the information is output.
    • HITRACE_FLAG_DONOT_ENABLE_LOG: Do not associate logs for output. By default, logs are associated for output.
    • HITRACE_FLAG_FAULT_TRIGGER: Triggers tracing by fault. By default, tracing is triggered normally.
    • HITRACE_FLAG_D2D_TP_INFO: Outputs the device-to-device tracepoint information. By default, the information is not output.
    • HITRCE_FLAG_DEFAULT: Indicates the default flag.
    -
  • Output arguments: none
  • Return value: Returns a valid HiTraceId object if call chain tracing is triggered successfully; returns an invalid object otherwise.
-

Note: In nested tracing mode, an invalid object will be returned if tracing is started at the nested layer.

-

void End(const HiTraceId& id)

-

Stops HiTraceChain based on the HiTraceId object returned by the Begin API, and clears the HiTraceId object in the TLS of the calling thread.

-

Input arguments:

-
  • id: Indicates the HiTraceId object.
-

Output arguments: none

-

Return value: none

-

HiTraceId GetId();

-

Obtains the HiTraceId object from the TLS of the calling thread.

-

Input arguments: none

-

Output arguments: none

-

Return value: Returns the HiTraceId object in the contextual TLS of the calling thread.

-

void SetId(const HiTraceId& id)

-

Purpose: Sets the HiTraceId object in the TLS of the calling thread.

-

Input arguments:

-
  • id: Indicates the HiTraceId object.
-

Output arguments: none

-

Return value: none

-

void ClearId()

-

Clears the HiTraceId object in the TLS of the current thread.

-

Input arguments: none

-

Output arguments: none

-

Return value: none

-

HiTraceId CreateSpan()

-

Obtains the span ID from the current HiTraceId object.

-

Input arguments: none

-

Output arguments: none

-

Return value: Returns the current span ID.

-

void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...)

-

Outputs HiTraceChain call chain information based on the information type. The information includes the timestamp and HiTraceId object information of the span.

-

Input arguments:

-
  • type: Indicates the information type. The options are as follows:
    • HITRACE_TP_CS: Client Send, which indicates the messages sent by the synchronous/asynchronous communication client.
    • HITRACE_TP_SR: Server Receive, which indicates the messages received by the server in synchronous/asynchronous communication.
    • HITRACE_TP_SS: Server Send, which indicates the response messages sent by the server in synchronous communication.
    • HITRACE_TP_CR: Client Receive, which indicates the response messages received by the synchronous communication client.
    • HITRACE_TP_GENERAL: Indicates the common output information.
    -
  • id: Indicates the ID of the current span.
  • fmt: Indicates the string describing the format variable parameter.
  • args: Indicates the variable parameter.
-

Output arguments: none

-

Return value: none

-

void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...)

-

Outputs HiTraceChain call chain information based on the communication mode and information type. The information includes the timestamp and HiTraceId object information of the span.

-

Input arguments:

-
  • mode: Indicates the communication mode. The options are as follows:
    • HITRACE_CM_DEFAULT: default communication mode used when no communication mode is specified
    • HITRACE_CM_THREAD: inter-thread communication
    • HITRACE_CM_PROCESS: inter-process communication
    • HITRACE_CM_DEVICE: inter-device communication
    -
  • type: Indicates the information type. The options are as follows:
    • HITRACE_TP_CS: Client Send, which indicates the messages sent by the synchronous/asynchronous communication client.
    • HITRACE_TP_SR: Server Receive, which indicates the messages received by the server in synchronous/asynchronous communication.
    • HITRACE_TP_SS: Server Send, which indicates the response messages sent by the server in synchronous communication.
    • HITRACE_TP_CR: Client Receive, which indicates the response messages received by the synchronous communication client.
    • HITRACE_TP_GENERAL: Indicates the common output information.
    -
  • id: Indicates the ID of the current span.
  • fmt: Indicates the string describing the format variable parameter.
  • args: Indicates the variable parameter.
-

Output arguments: none

-

Return value: none

-

HiTraceId

-

-

-

-

-

-

-

-

-

-

-

-

-

-

HiTraceId();

-

Represents the default constructor used to generate an invalid HiTraceId object.

-

Input arguments: none

-

Output arguments: none

-

Return value: none

-

HiTraceId(const uint8_t* pIdArray, int len)

-

Represents the constructor used to create a HiTraceId object based on the specified byte array.

-
Input arguments:
  • pIdArray: Indicates the pointer to a byte array.
  • len: Indicates the length of the byte array.
-
-

Output arguments: none

-

Return value: none

-

bool IsValid()

-

Checks whether the HiTraceId object is valid.

-

Input arguments: none

-

Output arguments: none

-

Return value: Returns true if the HiTraceId object is valid; returns false otherwise.

-

bool IsFlagEnabled(HiTraceFlag flag)

-

Checks whether the tracing flag of the HiTraceId object is enabled.

-

Input arguments:

-
  • flag: Indicates the tracing flag. For details, see the description in the Begin function.
-

Output arguments: none

-

Return value: Returns true if the tracing flag is enabled; returns false otherwise.

-

void EnableFlag(HiTraceFlag flag)

-

Enables the tracing flag of the HiTraceId object.

-

Input arguments:

-
  • flag: Indicates the tracing flag. For details, see the description in the Begin function.
-

Output arguments: none

-

Return value: none

-

int GetFlags()

-

Obtains the tracing flag set in the HiTraceId object.

-

Input arguments: none

-

Output arguments: none

-

Return value: Returns the combination of tracing flags. For details, see the description in the Begin function.

-

void SetFlags(int flags)

-

Sets a tracing flag in the HiTraceId object.

-

Input arguments:

-
  • flags: Indicates the combination of tracing flags. For details, see the description in the Begin function.
-

Output arguments: none

-

Return value: none

-

uint64_t GetChainId()

-

Obtains the call chain ID.

-

Input arguments: none

-

Output arguments: none

-

Return value: Returns the call chain ID.

-

void SetChainId(uint64_t chainId)

-

Sets the call chain ID in the HiTraceId object.

-

Input arguments:

-
  • chainId: Indicates the call chain ID.
-

Output arguments: none

-

Return value: none

-

uint64_t GetSpanId()

-

Obtains the span ID from the current HiTraceId object.

-

Input arguments: none

-

Output arguments: none

-

Return value: Returns the current span ID.

-

void SetSpanId(uint64_t spanId)

-

Sets the span ID in the HiTraceId object.

-

Input arguments:

-
  • spanId: Indicates the span ID.
-

Output arguments: none

-

Return value: none

-

uint64_t GetParentSpanId()

-

Obtains the parent span ID from the current HiTraceId object.

-

Input arguments: none

-

Output arguments: none

-

Return value: Returns the parent span ID.

-

void SetParentSpanId(uint64_t parentSpanId)

-

Sets the parent span ID in the HiTraceId object.

-

Input arguments:

-
  • parentSpanId: Indicates the parent span ID.
-

Output arguments: none

-

Return value: none

-

int ToBytes(uint8_t* pIdArray, int len)

-

Converts the HiTraceId object into a byte array to facilitate caching or communication transfer.

-

Input arguments:

-
  • pIdArray: Indicates the pointer to a byte array. The minimum length of the byte array is HITRACE_ID_LEN.
  • len: Indicates the length of the byte array.
-

Output arguments

-
  • pIdArray: Indicates the pointer to a byte array. If the object is valid, the object data after conversion is stored.
-

Return value: Returns a value greater than 0 (indicating a valid array of object data) if the conversion is successful; returns 0 otherwise.

-
- -## Call Chain Processing - -Inter-device, inter-process, and inter-thread calls are implemented through the communication mechanism. **HiTraceChain** requires transfer of **traceid** in the communication mechanism. - -Some built-in communication mechanisms \(such as ZIDL\) of OpenHarmony already support the transfer of **traceid**. - -The following figure shows the process of transferring **traceid** in synchronous call. The process of transferring **traceid** in asynchronous call is similar. - -Extended communication mechanisms can also follow this implementation. - -**Figure 5** Call chain tracing in synchronous communication - -![](figures/call-chain-tracing-in-synchronous-communication.png "call-chain-tracing-in-synchronous-communication") + **Table 2** Trace flag combination types + +| **Name**| **Value**| **Description**| +| -------- | -------- | -------- | +| HITRACE_FLAG_DEFAULT | 0 | Default flag. | +| HITRACE_FLAG_INCLUDE_ASYNC | 1 | Asynchronous call flag. By default, only synchronous calls are traced. If this flag is set, both synchronous and asynchronous calls will be traced. | +| HITRACE_FLAG_DONOT_CREATE_SPAN | 1 << 1 | No span flag. By default, spans are created within a trace of synchronous and asynchronous service calls. If this flag is set, no spans are created. | +| HITRACE_FLAG_TP_INFO | 1 << 2 | Trace point flag. By default, no trace point is added when trace is enabled. This flag is used for debugging. If this flag is set, trace points will be automatically added on the TX and RX sides of synchronous and asynchronous calls to output trace point and timestamp information. Trace points are classified into four types: client send (CS), server receive (SR), server send (SS), and client receive (CR). For a synchronous call, the output trace points are CS, SR, SS, and CR; for an asynchronous call, the output trace points are CS, SR, and SS. | +| HITRACE_FLAG_NO_BE_INFO | 1 << 3 | No begin/end flag. By default, information about the start and end of the trace task is printed. If this flag is set, information about the start and end of the trace task will not be printed.| +| HITRACE_FLAG_DONOT_ENABLE_LOG | 1 << 4 | Log association flag. If this flag is set, information about the trace task will not be printed. | +| HITRACE_FLAG_FAULT_TRIGGER | 1 << 5 | Failure trigger flag. This flag is reserved for future use. | +| HITRACE_FLAG_D2D_TP_INFO | 1 << 6 | Device-to-device trace point flag. It is a subset of **TP_INFO**. If this flag is set, trace points are added only for call chain trace between devices.| + + **Table 3** Trace point types + +| **Name**| **Value**| **Description**| +| -------- | -------- | -------- | +| HITRACE_TP_CS | 0 | CS trace point. | +| HITRACE_TP_CR | 1 | CR trace point. | +| HITRACE_TP_SS | 2 | SS trace point. | +| HITRACE_TP_SR | 3 | SR trace point. | +| HITRACE_TP_GENERAL | 4 | General trace points except CS, CR, SS, and SR.| + + **Table 4** Communication modes + +| **Name**| **Value**| **Description**| +| -------- | -------- | -------- | +| HITRACE_CM_DEFAULT | 0 | Default communication mode. | +| HITRACE_CM_THREAD | 1 | Inter-thread communication. | +| HITRACE_CM_PROCESS | 2 | Inter-process communication. | +| HITRACE_CM_DEVICE | 3 | Inter-device communication. | + + **Table 5** Description of C++ APIs + +| **Class**| **API**| **Description**| +| -------- | -------- | -------- | +| HiTraceChain | HiTraceId Begin(const std::string& name, int flags) | Starts HiTraceChain, generates a **HiTraceId** object, and sets it in the TLS of the calling thread.
Input arguments:
- **name**: name of the service process.
- **flags**: trace flags, which can be used in combination. For details, see Table 2.
Output arguments: none
Return value: a valid **HiTraceId** object if call chain trace is triggered successfully; returns an invalid object otherwise.
Note: In nested trace mode, an invalid object will be returned if trace is started at the nested layer.| +| | void End(const HiTraceId& id) | Stops HiTraceChain based on the **HiTraceId** object returned by the **Begin** API, and clears the **HiTraceId** object in the TLS of the calling thread.
Input arguments:
- **id**: **HiTraceId** object.
Output arguments: none
Return value: none| +| | HiTraceId GetId(); | Obtains the **HiTraceId** object from the TLS of the calling thread.
Input arguments: none
Output arguments: none
Return value: **HiTraceId** object in the contextual TLS of the calling thread.| +| | void SetId(const HiTraceId& id) | Purpose: Sets the **HiTraceId** object in the TLS of the calling thread.
Input arguments:
- **id**: **HiTraceId** object.
Output arguments: none
Return value: none| +| | void ClearId() | Clears the **HiTraceId** object in the TLS of the calling thread.
Input arguments: none
Output arguments: none
Return value: none| +| | HiTraceId CreateSpan() | Obtains the span ID from the current **HiTraceId** object.
Input arguments: none
Output arguments: none
Return value: current span ID.| +| | void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...) | Outputs HiTraceChain trace point information based on the information type. The information includes the timestamp and **HiTraceId** object of the span.
Input arguments:
- **type**: trace point type. For details, see Table 3.
- **id**: ID of the current span.
- **fmt**: string describing the format variable parameter.
- **args**: variable parameter.
Output arguments: none
Return value: none| +| | void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...) | Outputs HiTraceChain trace point information based on the communication mode and information type. The information includes the timestamp and **HiTraceId** object of the span.
Input arguments:
- **mode**: communication mode. For details, see Table 4.
- **type**: trace point type. For details, see Table 3.
- **id**: ID of the current span.
- **fmt**: string describing the format variable parameter.
- **args**: variable parameter.
Output arguments: none
Return value: none| +| HiTraceId | HiTraceId(); | Represents the default constructor used to generate an invalid **HiTraceId** object.
Input arguments: none
Output arguments: none
Return value: none| +| | HiTraceId(const uint8_t* pIdArray, int len) | Represents the constructor used to create a **HiTraceId** object based on the specified byte array.
Input arguments:
- **pIdArray**: pointer to a byte array.
- **len**: length of the byte array.
Output arguments: none
Return value: none| +| | bool IsValid() | Checks whether the **HiTraceId** object is valid.
Input arguments: none
Output arguments: none
Return value: **true** if the **HiTraceId** object is valid; **false** otherwise.| +| | bool IsFlagEnabled(HiTraceFlag flag) | Checks whether the trace flag of the **HiTraceId** object is enabled.
Input arguments:
- **flag**: trace flag. For details, see the description in the **Begin** function.
Output arguments: none
Return value: **true** if the trace flag is enabled; **false** otherwise.| +| | void EnableFlag(HiTraceFlag flag) | Enables the trace flag of the **HiTraceId** object.
Input arguments:
- **flag**: trace flag. For details, see the description in the **Begin** function.
Output arguments: none
Return value: none| +| | int GetFlags() | Obtains the trace flag set in the **HiTraceId** object.
Input arguments: none
Output arguments: none
Return value: Returns the combination of trace flags. For details, see the description in the **Begin** function.| +| | void SetFlags(int flags) | Sets a trace flag in the **HiTraceId** object.
Input arguments:
- **flags**: combination of trace flags. For details, see the description in the **Begin** function.
Output arguments: none
Return value: none| +| | uint64_t GetChainId() | Obtains the call chain ID.
Input arguments: none
Output arguments: none
Return value: call chain ID.| +| | void SetChainId(uint64_t chainId) | Sets the call chain ID in the **HiTraceId** object.
Input arguments:
- **chainId**: call chain ID.
Output arguments: none
Return value: none| +| | uint64_t GetSpanId() | Obtains the span ID from the current **HiTraceId** object.
Input arguments: none
Output arguments: none
Return value: current span ID.| +| | void SetSpanId(uint64_t spanId) | Sets the span ID in the **HiTraceId** object.
Input arguments:
- **spanId**: span ID.
Output arguments: none
Return value: none| +| | uint64_t GetParentSpanId() | Obtains the parent span ID from the current **HiTraceId** object.
Input arguments: none
Output arguments: none
Return value: parent span ID.| +| | void SetParentSpanId(uint64_t parentSpanId) | Sets the parent span ID in the **HiTraceId** object.
Input arguments:
- **parentSpanId**: parent span ID.
Output arguments: none
Return value: none| +| | int ToBytes(uint8_t* pIdArray, int len) | Converts the **HiTraceId** object into a byte array to facilitate caching or communication transfer.
Input arguments:
- **pIdArray**: pointer to a byte array. The minimum length of the byte array is **HITRACE_ID_LEN**.
- **len**: length of the byte array.
Output parameters:
- **pIdArray**: pointer to a byte array. If the object is valid, the object data after conversion is stored.
Return value: a value greater than **0** (indicating a valid array of object data) if the conversion is successful; **0** otherwise.| + + +### Call Chain Processing + +Inter-device, inter-process, and inter-thread calls are implemented through the communication mechanism. HiTraceChain requires transfer of **traceid** in the communication mechanism. + +Some built-in communication mechanisms (such as ZIDL) of OpenHarmony already support the transfer of **traceid**. + +The following figure shows the process of transferring **traceid** in synchronous call. The process of transferring **traceid** in asynchronous call is similar. + + Extended communication mechanisms can also follow this implementation. + + **Figure 5** Call chain trace in synchronous communication + + ![](figures/call-chain-trace-in-synchronous-communication.png "call-chain-trace-in-synchronous-communication") The process is as follows: -1. The service module on the client calls the **begin\(\)** function to start call chain tracing. -2. The service module on the client synchronously calls the **transact** function to the communication component on the client. -3. The communication component on the client performs the following: - 1. Obtains **traceid** from the TLS of the calling thread. - 2. Generates child **traceid**. - 3. Writes child **traceid** into the transaction data \(synchronous communication data\). - 4. Performs Client Send \(CS\) tracing. - 5. Sends communication data to the communication component on the server. - -4. On receiving the communication data, the communication component on the server performs the following: - 1. Obtains **traceid** from the data message package. - 2. Sets **traceid** in the TLS of the calling thread. - 3. Performs Server Receive \(SR\) tracing. - 4. Synchronously call the **onTransact** callback to the service module on the server. - -5. The service module on the server processes the service and sends the transact reply message carrying the processing result to the communication component. -6. The communication component on the server performs the following: - 1. Performs Server Send \(SS\) tracing. - 2. Sends communication data to the communication component on the client. - 3. Clears **traceid** from the TLS of the calling thread. - -7. On receiving the communication data, the communication component on the client performs the following: - 1. Performs Client Receive \(CR\) tracing. - 2. Sends a transact reply response to the service module on the client. - -8. The service module on the client processes the transact reply response. -9. When the process ends, the service module on the client calls the **end\(\)** function to stop call chain tracing. - -## How to Develop - -### C++ - -1. Develop the source code. +1. The service module on the client calls the **begin()** function to start call chain trace. - Include the **hitracechain** header file in the class definition header file or class implementation source file. For example: +2. The service module on the client synchronously calls the **transact** function to the communication component on the client. - ``` - #include "hitrace/tracechain.h" - ``` +3. The communication component on the client performs the following: + 1. Obtains **traceid** from the TLS of the calling thread. + 2. Generates child **traceid**. + 3. Writes child **traceid** into the transaction data (synchronous communication data). + 4. Performs CS trace. + 5. Sends communication data to the communication component on the server. - Add the code to start and stop call chain tracing in the class implementation source file. +4. On receiving the communication data, the communication component on the server performs the following: + 1. Obtains **traceid** from the data message package. + 2. Sets **traceid** in the TLS of the calling thread. + 3. Performs SR trace. + 4. Synchronously calls the **onTransact** callback to the service module on the server. - ``` - using namespace OHOS::HiviewDFX; - auto traceId = HiTraceChain::Begin("MyServiceFlow", HITRACE_FLAG_DEFAULT); - ... - HiTraceChain::End(traceId); - ``` +5. The service module on the server processes the service and sends the transact reply message carrying the processing result to the communication component. -2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. +6. The communication component on the server performs the following: + 1. Performs SS trace. + 2. Sends communication data to the communication component on the client. + 3. Clears **traceid** from the TLS of the calling thread. - ``` - external_deps = [ "hiviewdfx:libhitracechain" ] - ``` +7. On receiving the communication data, the communication component on the client performs the following: + 1. Performs CR trace. + 2. Sends a transact reply response to the service module on the client. +8. The service module on the client processes the transact reply response. -### C +9. When the process ends, the service module on the client calls the **end()** function to stop call chain trace. -1. Develop the source code. - Include the **hitracechain** header file in the source file. - - ``` - #include "hitrace/tracechain.h" - ``` - - Add the code to start and stop call chain tracing in the class implementation source file. - - ``` - HiTraceIdStruct traceId = HiTraceChainBegin("MyServiceFlow", HITRACE_FLAG_DEFAULT); - ... - HiTraceChainEnd(traceId); - ``` - -2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. - - ``` - external_deps = [ "hiviewdfx:libhitracechain" ] - ``` +## How to Develop +### **C++** + +1. Develop the source code. + Include the **hitracechain** header file in the class definition header file or class implementation source file. For example: + + ``` + #include "hitrace/tracechain.h" + ``` + + Add the code to start and stop call chain trace in the class implementation source file. + + ``` + using namespace OHOS::HiviewDFX; + auto traceId = HiTraceChain::Begin("MyServiceFlow", HITRACE_FLAG_DEFAULT); + ...... + HiTraceChain::End(traceId); + ``` + +2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. + + ``` + external_deps = [ "hiviewdfx:libhitracechain" ] + ``` + + +### **C** + +1. Develop the source code. + Include the **hitracechain** header file in the source file. + + ``` + #include "hitrace/tracechain.h" + ``` + + Add the code to start and stop call chain trace in the class implementation source file. + + ``` + HiTraceIdStruct traceId = HiTraceChainBegin("MyServiceFlow", HITRACE_FLAG_DEFAULT); + ...... + HiTraceChainEnd(traceId); + ``` + +2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. + + ``` + external_deps = [ "hiviewdfx:libhitracechain" ] + ``` diff --git a/en/device-dev/subsystems/subsys-dfx-hitracemeter.md b/en/device-dev/subsystems/subsys-dfx-hitracemeter.md index e80731582852658e6a65c6fc8f8d7cb66ca746a0..bb609b7369d03ae82b7782421c3ec96344bcc840 100644 --- a/en/device-dev/subsystems/subsys-dfx-hitracemeter.md +++ b/en/device-dev/subsystems/subsys-dfx-hitracemeter.md @@ -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). diff --git a/en/device-dev/subsystems/subsys-dfx-overview.md b/en/device-dev/subsystems/subsys-dfx-overview.md index b7487c10632d95533a94b29c78a340fbb808d17c..623ed60d365a662b8e11bb6b8489128481eabe2f 100644 --- a/en/device-dev/subsystems/subsys-dfx-overview.md +++ b/en/device-dev/subsystems/subsys-dfx-overview.md @@ -1,36 +1,47 @@ -# DFX Overview +# DFX Overview -[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\). + +## 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 +## 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. diff --git a/en/release-notes/OpenHarmony-1-0.md b/en/release-notes/OpenHarmony-1-0.md index 59bad423d7a587ef7c23f49b58bec58bb93faea7..2a8b3fb7408bdbeb822d157867e1064ff76a07d7 100644 --- a/en/release-notes/OpenHarmony-1-0.md +++ b/en/release-notes/OpenHarmony-1-0.md @@ -1,4 +1,4 @@ -# OpenHarmony 1.0 \(2020-09-10) +# OpenHarmony 1.0 \(2020-09-10) (EOL) ## Overview diff --git a/en/release-notes/OpenHarmony-1-1-0-LTS.md b/en/release-notes/OpenHarmony-1-1-0-LTS.md index 2876c8a94fa57750f5a66e688e6e3f86bcf5cef7..5c80392132f61db0f9a4869e36a9f128042e0dc2 100644 --- a/en/release-notes/OpenHarmony-1-1-0-LTS.md +++ b/en/release-notes/OpenHarmony-1-1-0-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony 1.1.0 LTS \(2021-04-01\) +# OpenHarmony 1.1.0 LTS \(2021-04-01\) (EOL) ## Overview diff --git a/en/release-notes/OpenHarmony-1-1-1-LTS.md b/en/release-notes/OpenHarmony-1-1-1-LTS.md index 03653f2552a5ad06e7d326fc5adbeb459d3d4618..5d414849d3185be9aa7bb3425657b3944eb8bbe4 100644 --- a/en/release-notes/OpenHarmony-1-1-1-LTS.md +++ b/en/release-notes/OpenHarmony-1-1-1-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony 1.1.1 LTS \(2021-06-22) +# OpenHarmony 1.1.1 LTS \(2021-06-22) (EOL) ## Version Description diff --git a/en/release-notes/OpenHarmony-v1-1-3-LTS.md b/en/release-notes/OpenHarmony-v1-1-3-LTS.md index de7054e735c4fafcc872aad6834c4715d6fc1c85..1561a988fbb066eb4f5398776face7455774678c 100644 --- a/en/release-notes/OpenHarmony-v1-1-3-LTS.md +++ b/en/release-notes/OpenHarmony-v1-1-3-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony v1.1.3 LTS +# OpenHarmony v1.1.3 LTS (EOL) ## Overview diff --git a/en/release-notes/OpenHarmony-v1-1-4-LTS.md b/en/release-notes/OpenHarmony-v1-1-4-LTS.md index 1854f89a4084873937bb7540fbe5afe1484916b4..7d79ea43af25bdcc49d22bd4ad06707f4a2ec75f 100644 --- a/en/release-notes/OpenHarmony-v1-1-4-LTS.md +++ b/en/release-notes/OpenHarmony-v1-1-4-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony 1.1.4 LTS +# OpenHarmony 1.1.4 LTS (EOL) ## Version Description diff --git a/en/release-notes/OpenHarmony-v1.1.2-LTS.md b/en/release-notes/OpenHarmony-v1.1.2-LTS.md index 8f897f2d83e546c6b31fc1e86e23284a831728c6..618b579d7a30f965ad9231e4ed26e001e76f5341 100644 --- a/en/release-notes/OpenHarmony-v1.1.2-LTS.md +++ b/en/release-notes/OpenHarmony-v1.1.2-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony v1.1.2 LTS +# OpenHarmony v1.1.2 LTS (EOL) ## Overview diff --git a/en/release-notes/OpenHarmony-v1.1.5-LTS.md b/en/release-notes/OpenHarmony-v1.1.5-LTS.md index 29819a02acd4bed740a156a68860ee24e0cc521a..3659590bbf77490c05c34d70ff711e3946c993e2 100644 --- a/en/release-notes/OpenHarmony-v1.1.5-LTS.md +++ b/en/release-notes/OpenHarmony-v1.1.5-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony 1.1.5 LTS +# OpenHarmony 1.1.5 LTS (EOL) ## Version Description diff --git a/en/release-notes/OpenHarmony-v3.1.2-release.md b/en/release-notes/OpenHarmony-v3.1.2-release.md index b474dfb8cd8c18b126368c3945b51ecec7f5ae9f..589aa08e513f33b296a416ce82e1a2f02601ca7f 100644 --- a/en/release-notes/OpenHarmony-v3.1.2-release.md +++ b/en/release-notes/OpenHarmony-v3.1.2-release.md @@ -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)| diff --git a/en/release-notes/OpenHarmony-v3.1.3-release.md b/en/release-notes/OpenHarmony-v3.1.3-release.md index 8029072be5610bf4b065f4295c44dc54183c33b8..e1735530034ffc05b9239944563351d812bf261a 100644 --- a/en/release-notes/OpenHarmony-v3.1.3-release.md +++ b/en/release-notes/OpenHarmony-v3.1.3-release.md @@ -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)| diff --git a/en/release-notes/Readme.md b/en/release-notes/Readme.md index de2478b990ec99ec4eeb16ad5117796ad1baee82..cea8e3824c0ca7db33af76ed089a1140e4802b17 100644 --- a/en/release-notes/Readme.md +++ b/en/release-notes/Readme.md @@ -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) diff --git a/zh-cn/application-dev/application-models/ability-startup-with-implicit-want.md b/zh-cn/application-dev/application-models/ability-startup-with-implicit-want.md index 643b8931eee32882fd66ba9bbccb8acd075ce201..ac6af46ca51c5798877dbc834103f4eb4c977805 100644 --- a/zh-cn/application-dev/application-models/ability-startup-with-implicit-want.md +++ b/zh-cn/application-dev/application-models/ability-startup-with-implicit-want.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) diff --git a/zh-cn/application-dev/application-models/application-context-stage.md b/zh-cn/application-dev/application-models/application-context-stage.md index b959ddaadb8146f814ef151b785c08ce61a09b22..b734131b18246d0ec6ce82399cca6957dd91dd45 100644 --- a/zh-cn/application-dev/application-models/application-context-stage.md +++ b/zh-cn/application-dev/application-models/application-context-stage.md @@ -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 | 是 | 否 | 应用在内部存储上的缓存路径。
对应于"设置 > 应用管理",找到对应应用的"存储"中的缓存内容。 | -| tempDir | string | 是 | 否 | 应用的临时文件路径。
在应用卸载后,系统会删除存储在此目录中的文件。 | -| filesDir | string | 是 | 否 | 应用在内部存储上的文件路径。
本目录下存放的文件可能会被应用迁移或者备份的时候同步到其他目录中。 | -| databaseDir | string | 是 | 否 | 获取本地数据库存储路径。 | -| bundleCodeDir | string | 是 | 否 | 应用在内部存储上的安装路径。 | -| distributedFilesDir | string | 是 | 否 | 应用的分布式文件路径。 | -| preferencesDir | string | 是 | 是 | 指示应用程序首选项目录。 | +| bundleCodeDir | string | 是 | 否 | 安装文件路径。应用在内部存储上的安装路径。 | +| cacheDir | string | 是 | 否 | 应用缓存文件路径。应用在内部存储上的缓存路径。
对应于“设置 > 应用管理”,找到对应应用的“存储”中的缓存内容。 | +| filesDir | string | 是 | 否 | 应用通用文件路径。应用在内部存储上的文件路径。
本目录下存放的文件可能会被应用迁移或者备份的时候同步到其他目录中。 | +| preferencesDir | string | 是 | 是 | 应用首选项文件路径。指示应用程序首选项目录。 | +| tempDir | string | 是 | 否 | 应用临时文件路径。
在应用卸载后,系统会删除存储在此目录中的文件。 | +| 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,19 +208,20 @@ 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#配置文件权限声明)。 + > > - 接口为系统接口,三方应用不支持调用。 - + ```ts import UIAbility from '@ohos.app.ability.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); } } ``` diff --git a/zh-cn/application-dev/application-models/data-share-via-want.md b/zh-cn/application-dev/application-models/data-share-via-want.md index 82173c8d066192ec738f515b191fa27494ffae1b..e23e11d2404c97a1cb7e9a57cd4aaf1487f51e75 100644 --- a/zh-cn/application-dev/application-models/data-share-via-want.md +++ b/zh-cn/application-dev/application-models/data-share-via-want.md @@ -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 } } } } diff --git a/zh-cn/application-dev/application-models/uiability-intra-device-interaction.md b/zh-cn/application-dev/application-models/uiability-intra-device-interaction.md index 298ec3f6bf415a2a5e036969df20452877a8c5b4..fafbe6935b781117851968f32e87ad339fcfc252 100644 --- a/zh-cn/application-dev/application-models/uiability-intra-device-interaction.md +++ b/zh-cn/application-dev/application-models/uiability-intra-device-interaction.md @@ -31,45 +31,52 @@ 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', - abilityName: 'FuncAbility', - moduleName: 'module1', // moduleName非必选 - parameters: { // 自定义信息 - info: '来自EntryAbility Index页面', - }, + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.example.myapplication', + abilityName: 'FuncAbility', + moduleName: 'module1', // moduleName非必选 + parameters: { // 自定义信息 + info: '来自EntryAbility Index页面', + }, } // 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'; import window from '@ohos.window'; export default class FuncAbility extends UIAbility { - onCreate(want, launchParam) { - // 接收调用方UIAbility传过来的参数 - let funcAbilityWant = want; - let info = funcAbilityWant?.parameters?.info; - // ... - } + onCreate(want, launchParam) { + // 接收调用方UIAbility传过来的参数 + let funcAbilityWant = want; + let info = funcAbilityWant?.parameters?.info; + // ... + } } ``` + > **说明:** + > + > 在被拉起的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,60 +94,63 @@ 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', - abilityName: 'FuncAbility', - moduleName: 'module1', // moduleName非必选 - parameters: { // 自定义信息 - info: '来自EntryAbility Index页面', - }, + deviceId: '', // deviceId为空表示本设备 + bundleName: 'com.example.myapplication', + abilityName: 'FuncAbility', + moduleName: 'module1', // moduleName非必选 + parameters: { // 自定义信息 + info: '来自EntryAbility Index页面', + }, } // context为调用方UIAbility的UIAbilityContext - this.context.startAbilityForResult(wantInfo).then((data) => { - // ... + context.startAbilityForResult(wantInfo).then((data) => { + // ... }).catch((err) => { - // ... + // ... }) ``` - + 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, - want: { - bundleName: 'com.example.myapplication', - abilityName: 'FuncAbility', - moduleName: 'module1', - parameters: { - info: '来自FuncAbility Index页面', - }, + resultCode: RESULT_CODE, + want: { + bundleName: 'com.example.myapplication', + abilityName: 'FuncAbility', + moduleName: 'module1', + parameters: { + info: '来自FuncAbility Index页面', }, + }, } // context为被调用方UIAbility的AbilityContext - this.context.terminateSelfWithResult(abilityResult, (err) => { - // ... + context.terminateSelfWithResult(abilityResult, (err) => { + // ... }); ``` - + 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) => { - if (data?.resultCode === RESULT_CODE) { - // 解析被调用方UIAbility返回的信息 - let info = data.want?.parameters?.info; - // ... - } - }).catch((err) => { + context.startAbilityForResult(wantInfo).then((data) => { + if (data?.resultCode === RESULT_CODE) { + // 解析被调用方UIAbility返回的信息 + let info = data.want?.parameters?.info; // ... + } + }).catch((err) => { + // ... }) ``` @@ -186,32 +196,35 @@ 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. - // bundleName: 'com.example.myapplication', - action: 'ohos.want.action.viewData', - // entities can be omitted. - entities: ['entity.system.default'], + deviceId: '', // deviceId为空表示本设备 + // uncomment line below if wish to implicitly query only in the specific bundle. + // bundleName: 'com.example.myapplication', + action: 'ohos.want.action.viewData', + // entities can be omitted. + entities: ['entity.system.default'], } // context为调用方UIAbility的UIAbilityContext - this.context.startAbility(wantInfo).then(() => { - // ... + context.startAbility(wantInfo).then(() => { + // ... }).catch((err) => { - // ... + // ... }) ``` - + 效果示意如下图所示,点击“打开PDF文档”时,会弹出选择框供用户选择。 ![](figures/uiability-intra-device-interaction.png) 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,47 +262,50 @@ 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. - // bundleName: 'com.example.myapplication', - action: 'ohos.want.action.editData', - // entities can be omitted. - entities: ['entity.system.default'], + deviceId: '', // deviceId为空表示本设备 + // uncomment line below if wish to implicitly query only in the specific bundle. + // bundleName: 'com.example.myapplication', + action: 'ohos.want.action.editData', + // entities can be omitted. + entities: ['entity.system.default'], } // context为调用方UIAbility的UIAbilityContext - this.context.startAbilityForResult(wantInfo).then((data) => { - // ... + context.startAbilityForResult(wantInfo).then((data) => { + // ... }).catch((err) => { - // ... + // ... }) ``` - + 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, - want: { - bundleName: 'com.example.myapplication', - abilityName: 'EntryAbility', - moduleName: 'entry', - parameters: { - payResult: 'OKay', - }, + resultCode: RESULT_CODE, + want: { + bundleName: 'com.example.myapplication', + abilityName: 'EntryAbility', + moduleName: 'entry', + parameters: { + payResult: 'OKay', }, + }, } // context为被调用方UIAbility的AbilityContext - this.context.terminateSelfWithResult(abilityResult, (err) => { - // ... + context.terminateSelfWithResult(abilityResult, (err) => { + // ... }); ``` - + 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,14 +313,14 @@ UIAbility是系统调度的最小单元。在设备内的功能模块之间跳 }; // context为调用方UIAbility的UIAbilityContext - this.context.startAbilityForResult(want).then((data) => { - if (data?.resultCode === RESULT_CODE) { - // 解析被调用方UIAbility返回的信息 - let payResult = data.want?.parameters?.payResult; - // ... - } - }).catch((err) => { + context.startAbilityForResult(want).then((data) => { + if (data?.resultCode === RESULT_CODE) { + // 解析被调用方UIAbility返回的信息 + let payResult = data.want?.parameters?.payResult; // ... + } + }).catch((err) => { + // ... }) ``` @@ -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) => { // ... @@ -397,25 +415,25 @@ import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' export default class FuncAbility extends UIAbility { - funcAbilityWant; - - onCreate(want, launchParam) { - // 接收调用方UIAbility传过来的参数 - this.funcAbilityWant = want; - } - - onWindowStageCreate(windowStage: Window.WindowStage) { - // Main window is created, set main page for this ability - let url = 'pages/Index'; - if (this.funcAbilityWant?.parameters?.router) { - if (this.funcAbilityWant.parameters.router === 'funA') { - url = 'pages/Second'; - } - } - windowStage.loadContent(url, (err, data) => { - // ... - }); + funcAbilityWant; + + onCreate(want, launchParam) { + // 接收调用方UIAbility传过来的参数 + this.funcAbilityWant = want; + } + + onWindowStageCreate(windowStage: Window.WindowStage) { + // Main window is created, set main page for this ability + let url = 'pages/Index'; + if (this.funcAbilityWant?.parameters?.router) { + if (this.funcAbilityWant.parameters.router === 'funA') { + url = 'pages/Second'; + } } + windowStage.loadContent(url, (err, data) => { + // ... + }); + } } ``` @@ -434,11 +452,11 @@ export default class FuncAbility extends UIAbility { import UIAbility from '@ohos.app.ability.UIAbility' export default class FuncAbility extends UIAbility { - onNewWant(want, launchParam) { - // 接收调用方UIAbility传过来的参数 - globalThis.funcAbilityWant = want; - // ... - } + onNewWant(want, launchParam) { + // 接收调用方UIAbility传过来的参数 + globalThis.funcAbilityWant = want; + // ... + } } ``` @@ -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的启动模式。 + + 例如将CalleeAbility配置为单实例模式`singleton`,配置方式请参见[UIAbility组件启动模式](uiability-launch-type.md)。 - ```json - "abilities":[{ - "name": ".CalleeAbility", - "srcEntrance": "./ets/CalleeAbility/CalleeAbility.ts", - "launchType": "singleton", - "description": "$string:CalleeAbility_desc", - "icon": "$media:icon", - "label": "$string:CalleeAbility_label", - "visible": true - }] - ``` - 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 - } + constructor(num, string) { + this.num = num; + this.str = string; + } - marshalling(messageSequence) { - messageSequence.writeInt(this.num) - messageSequence.writeString(this.str) - return true - } + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); + return true + } - unmarshalling(messageSequence) { - this.num = messageSequence.readInt() - this.str = messageSequence.readString() - return true - } + unmarshalling(messageSequence) { + 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 @@ -606,34 +606,34 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe const MSG_SEND_METHOD: string = 'CallSendMsg'; function sendMsgCallback(data) { - console.info('CalleeSortFunc called'); + console.info('CalleeSortFunc called'); - // 获取Caller发送的序列化数据 - let receivedData = new MyParcelable(0, ''); - data.readParcelable(receivedData); - console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`); + // 获取Caller发送的序列化数据 + let receivedData = new MyParcelable(0, ''); + data.readParcelable(receivedData); + console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`); - // 作相应处理 - // 返回序列化数据result给Caller - return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`); + // 作相应处理 + // 返回序列化数据result给Caller + return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`); } - export default class CalleeAbility extends Ability { - onCreate(want, launchParam) { - try { - this.callee.on(MSG_SEND_METHOD, sendMsgCallback); - } catch (error) { - console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`); - } + export default class CalleeAbility extends UIAbility { + onCreate(want, launchParam) { + try { + this.callee.on(MSG_SEND_METHOD, sendMsgCallback); + } catch (error) { + console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`); } + } - onDestroy() { - try { - this.callee.off(MSG_SEND_METHOD); - } catch (error) { - console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`); - } + onDestroy() { + try { + this.callee.off(MSG_SEND_METHOD); + } catch (error) { + console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`); } + } } ``` @@ -643,40 +643,40 @@ 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) => { - console.info(`caller onRelease is called ${msg}`); - }) - console.info('caller register OnRelease succeed'); - } catch (error) { - console.info(`caller register OnRelease failed with ${error}`); - } + try { + caller.on('release', (msg) => { + console.info(`caller onRelease is called ${msg}`); + }) + console.info('caller register OnRelease succeed'); + } catch (error) { + console.info(`caller register OnRelease failed with ${error}`); + } } async onButtonGetCaller() { - try { - this.caller = await context.startAbilityByCall({ - bundleName: 'com.samples.CallApplication', - abilityName: 'CalleeAbility' - }) - if (this.caller === undefined) { - console.info('get caller failed') - return - } - console.info('get caller success') - this.regOnRelease(this.caller) - } catch (error) { - console.info(`get caller failed with ${error}`) + try { + this.caller = await context.startAbilityByCall({ + bundleName: 'com.samples.CallApplication', + abilityName: 'CalleeAbility' + }) + if (this.caller === undefined) { + console.info('get caller failed') + return } + console.info('get caller success') + this.regOnRelease(this.caller) + } catch (error) { + console.info(`get caller failed with ${error}`) + } } ``` diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 95ad5e7b6db5ff249511dca9841dae46e6c9b66d..c128daff39dbe566fb49eb253d268a237b405b68 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -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) diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-want.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-want.md index 6b938dfa1c2dfa3ff782f61f09f1763280a3fc71..ba737871aa6fb6434745828b4c551e6cf9cdae51 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-want.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-want.md @@ -26,7 +26,7 @@ import Want from '@ohos.app.ability.Want'; | entities | Array\ | 否 | 表示目标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值:
- ohos.aafwk.callerPid:表示拉起方的pid。
- ohos.aafwk.param.callerToken:表示拉起方的token。
- ohos.aafwk.param.callerUid:表示[BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。
- component.startup.newRules:表示是否启用新的管控规则。
- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。
- ohos.dlp.params.sandbox:表示dlp文件才会有。 | +| parameters | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:
- ohos.aafwk.callerPid:表示拉起方的pid。
- ohos.aafwk.param.callerBundleName:表示拉起方的Bundle Name。
- ohos.aafwk.param.callerToken:表示拉起方的token。
- ohos.aafwk.param.callerUid:表示[BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。
- component.startup.newRules:表示是否启用新的管控规则。
- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。
- ohos.dlp.params.sandbox:表示dlp文件才会有。 | | [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | 否 | 表示处理Want的方式。默认传数字。
例如通过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)}'); + fd = fs.openSync('/data/storage/el2/base/haps/pic.png').fd; + } 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}`); }); ``` - diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index bfc30141778b66e77e3fa527d418373c6246b960..279865ea3c8f8d367f0be83d945e8b9b21e0a017 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -5044,7 +5044,7 @@ on(type: 'audioInterrupt', callback: Callback\): 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\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 事件回调类型,支持的事件为:'audioInterrupt'(中断事件被触发,音频播放被中断。) | -| callback | Callback<[InterruptEvent](#interruptevent9)> | 是 | 被监听的中断事件的回调。 | +| type | string | 是 | 事件回调类型,支持的事件为:'audioInterrupt'(中断事件被触发,音频渲染被中断。) | +| callback | Callback\<[InterruptEvent](#interruptevent9)\> | 是 | 被监听的中断事件的回调。 | **错误码:** @@ -5066,50 +5066,68 @@ on(type: 'audioInterrupt', callback: Callback\): 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')10+ + +on(type: 'audioInterrupt', callback: Callback\): 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')8+ on(type: "markReach", frame: number, callback: Callback<number>): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-file-fileUri.md b/zh-cn/application-dev/reference/apis/js-apis-file-fileuri.md similarity index 93% rename from zh-cn/application-dev/reference/apis/js-apis-file-fileUri.md rename to zh-cn/application-dev/reference/apis/js-apis-file-fileuri.md index 595a3a593dad5d384dbc7ff832285e07cd9b031a..acf1eb72d5a85f823a743a396be2c70459ae5f3c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-file-fileUri.md +++ b/zh-cn/application-dev/reference/apis/js-apis-file-fileuri.md @@ -1,4 +1,4 @@ -# @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); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-file-fs.md b/zh-cn/application-dev/reference/apis/js-apis-file-fs.md index 9bc6e12e371d0c6f1517870fc8b3a6589dddd224..7e02d86f1e15bdabfd75664f39cd4ebe42bf7491 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-file-fs.md +++ b/zh-cn/application-dev/reference/apis/js-apis-file-fs.md @@ -955,7 +955,7 @@ truncate(file: string|number, len?: number): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | -------------------------------- | | file | string\|number | 是 | 文件的应用沙箱路径或已打开的文件描述符fd。 | -| len | number | 否 | 文件截断后的长度,以字节为单位。 | +| len | number | 否 | 文件截断后的长度,以字节为单位。默认为0。 | **返回值:** @@ -989,7 +989,7 @@ truncate(file: string|number, len?: number, callback: AsyncCallback<void>) | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | -------------------------------- | | file | string\|number | 是 | 文件的应用沙箱路径或已打开的文件描述符fd。 | -| len | number | 否 | 文件截断后的长度,以字节为单位。 | +| len | number | 否 | 文件截断后的长度,以字节为单位。默认为0。 | | callback | AsyncCallback<void> | 是 | 回调函数,本调用无返回值。 | **示例:** @@ -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<string[]> | 是 | 异步列出文件名数组之后的回调。 | **options参数说明:** @@ -1679,7 +1679,7 @@ listFileSync(path: string, options?: { | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | --------------------------- | | path | string | 是 | 文件夹的应用沙箱路径。 | - | options | Object | 否 | 文件过滤选项。 | + | options | Object | 否 | 文件过滤选项。默认不进行过滤。 | **options参数说明:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index f60cfaed73ab60480c0f13be76391cd404214a7c..b5d9217c84dd68aaed217f1d59ed605234ad1dbd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -617,6 +617,7 @@ remove(callback: AsyncCallback<boolean>): void ``` ## UploadConfig +上传任务的配置信息。 **需要权限**:ohos.permission.INTERNET @@ -631,6 +632,7 @@ remove(callback: AsyncCallback<boolean>): void | data | Array<[RequestData](#requestdata)> | 是 | 请求的表单数据。 | ## TaskState9+ +上传任务信息,[on('complete' | 'fail')9+](#oncomplete--fail9)和[off('complete' | 'fail')9+](#offcomplete--fail9)接口的回调参数。 **需要权限**:ohos.permission.INTERNET @@ -643,6 +645,7 @@ remove(callback: AsyncCallback<boolean>): void | message | string | 是 | 上传任务结果描述信息 | ## File +[UploadConfig](#uploadconfig)中的文件列表。 **需要权限**:ohos.permission.INTERNET @@ -657,6 +660,7 @@ remove(callback: AsyncCallback<boolean>): void ## RequestData +[UploadConfig](#uploadconfig)中的表单数据。 **需要权限**:ohos.permission.INTERNET @@ -1657,6 +1661,7 @@ resume(callback: AsyncCallback<void>): void ## DownloadConfig +下载任务的配置信息。 **需要权限**:ohos.permission.INTERNET @@ -1676,6 +1681,7 @@ resume(callback: AsyncCallback<void>): void ## DownloadInfo7+ +下载任务信息,[query(deprecated)](#querydeprecated-1)接口的回调参数。 **需要权限**:ohos.permission.INTERNET @@ -1693,4 +1699,6 @@ resume(callback: AsyncCallback<void>): void | downloadTitle | string | 是 | 下载任务名称。 | | downloadTotalBytes | number | 是 | 下载的文件的总大小(int bytes)。 | | description | string | 是 | 待下载文件的描述信息。 | -| downloadedBytes | number | 是 | 实时下载大小(int  bytes)。 | \ No newline at end of file +| downloadedBytes | number | 是 | 实时下载大小(int  bytes)。 | + + \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-webview.md b/zh-cn/application-dev/reference/apis/js-apis-webview.md index 0196bb4a3257d79223c05dc2ebf74ef79b370eb1..5f49df9bfe7ad1b992b53c5259061debb220ee3a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webview.md @@ -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() { diff --git a/zh-cn/application-dev/reference/apis/test.txt b/zh-cn/application-dev/reference/apis/test.txt deleted file mode 100644 index b464861d9f38abbd9893395100b807e99a0aa873..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/test.txt +++ /dev/null @@ -1 +0,0 @@ -e \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md index a3781242346241c0874800558095b6c205a0a0c2..fcbada6f9aaf0caa933d0cb1b17231e5ef8bf4e9 100755 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -3099,6 +3099,42 @@ onAudioStateChanged(callback: (event: { playing: boolean }) => void) } ``` +### onFirstContentfulPaint10+ + +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) + }) + } + } + } + ``` + ### onLoadIntercept10+ onLoadIntercept(callback: (event?: { data: WebResourceRequest }) => boolean) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index f3b2f7d831c4d6fc6d83ae28e222238d8215d79f..2b9226798f870d35fb1d06072aab189e4d5a8a1f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -42,7 +42,7 @@ | builder | [CustomBuilder](ts-types.md#custombuilder8) | 是 | 提示气泡内容的构造器。 | | placement | [Placement](ts-appendix-enums.md#placement8) | 否 | 气泡组件优先显示的位置,当前位置显示不下时,会自动调整位置。
默认值:Placement.Bottom | | popupColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 提示气泡的颜色。 | -| enableArrow | boolean | 否 | 是否显示箭头。
从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度的两倍(64vp),则实际不会显示箭头。
默认值:true | +| enableArrow | boolean | 否 | 是否显示箭头。
从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,此时如果气泡高度小于箭头的宽度(32vp)与气泡圆角两倍(48vp)之和(80vp),则实际不会显示箭头。
默认值:true | | autoCancel | boolean | 否 | 页面有操作时,是否自动关闭气泡。
默认值:true | | onStateChange | (event: { isVisible: boolean }) => void | 否 | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 | | arrowOffset9+ | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,数值为0表示箭头居最左侧,偏移量为箭头至最左侧的距离,默认居中。箭头在气泡左右侧时,偏移量为箭头至最上侧的距离,默认居中。如果显示在屏幕边缘,气泡会自动左右偏移,数值为0时箭头始终指向绑定组件。 | diff --git a/zh-cn/application-dev/reference/native-apis/_mind_spore.md b/zh-cn/application-dev/reference/native-apis/_mind_spore.md index 57d24f5758b2a53cee3d86da8e59f3bf07181668..dee9088c444b0a20e691f168170b29b892bd831a 100644 --- a/zh-cn/application-dev/reference/native-apis/_mind_spore.md +++ b/zh-cn/application-dev/reference/native-apis/_mind_spore.md @@ -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相关的接口,可以配置运行时信息。
引用文件:\ | +| [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支持的模型文件类型和设备类型。
引用文件:\ | ### 结构体 diff --git a/zh-cn/application-dev/reference/native-apis/_neural_nework_runtime.md b/zh-cn/application-dev/reference/native-apis/_neural_nework_runtime.md index e265384899356daddc00292c13c345bd28152d49..71314462cb1b34f6fb1a4c191d2b089d120c3024 100644 --- a/zh-cn/application-dev/reference/native-apis/_neural_nework_runtime.md +++ b/zh-cn/application-dev/reference/native-apis/_neural_nework_runtime.md @@ -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接口,完成模型构造与编译,并在加速硬件上执行推理计算。
引用文件:\ | +| [neural_network_runtime_type.h](neural__network__runtime__type_8h.md) | Neural Network Runtime定义的结构体和枚举值。
引用文件:\ | ### 结构体 diff --git a/zh-cn/application-dev/reference/native-apis/native__avcodec__base_8h.md b/zh-cn/application-dev/reference/native-apis/native__avcodec__base_8h.md index b97542018deb536c968092148abab85c8f06cfa0..457fd4b628f8d8a3968c09ab85409534c8f8b6bd 100644 --- a/zh-cn/application-dev/reference/native-apis/native__avcodec__base_8h.md +++ b/zh-cn/application-dev/reference/native-apis/native__avcodec__base_8h.md @@ -54,23 +54,23 @@ | 名称 | 描述 | | -------- | -------- | -| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc) | const char \*
AVC视频编解码器的MIME类型。| -| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac) | const char \*
AAC音频编解码器的MIME类型。| -| [OH_ED_KEY_TIME_STAMP](_codec_base.md#oh_ed_key_time_stamp) | const char \*
提供统一的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 \*
为媒体播放框架提供统一的字符描述符。| -| [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。 | diff --git a/zh-cn/application-dev/reference/native-apis/rawfile.md b/zh-cn/application-dev/reference/native-apis/rawfile.md index c416450e827cde5420c6cda924c0b8c687243fc1..286cbd6f131c777f0681ee362716462f69bbafc9 100644 --- a/zh-cn/application-dev/reference/native-apis/rawfile.md +++ b/zh-cn/application-dev/reference/native-apis/rawfile.md @@ -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目录相关功能。
引用文件:\ | +| [raw_file.h](raw__file_8h.md) | 提供rawfile文件相关功能。
引用文件:\ | +| [raw_file_manager.h](raw__file__manager_8h.md) | 提供资源管理rawfile相关功能。
引用文件:\ | ### 结构体 diff --git a/zh-cn/application-dev/security/cryptoFramework-guidelines.md b/zh-cn/application-dev/security/cryptoFramework-guidelines.md index 934a986b4b775e0c2b55da87764323584516ca2e..cbfd2ba12b1b336730567bc1aafd45f98c3a45a7 100644 --- a/zh-cn/application-dev/security/cryptoFramework-guidelines.md +++ b/zh-cn/application-dev/security/cryptoFramework-guidelines.md @@ -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.generateKeyPair(function (err, keyPair) { - globalKeyPair = keyPair; - eccKeyAgreement.generateSecret(keyPair.priKey, keyPair.pubKey, function (err, secret) { - if (err) { - console.error("ecdh error."); - return; - } - console.info("ecdh output is " + secret.data); + eccGenerator.convertKey(peerPubKeyBlob, null, function (err, peerKeyPair) { + globalPeerPubKey = peerKeyPair.pubKey; + eccGenerator.generateKeyPair(function (err, keyPair) { + globalSelfPriKey = keyPair.priKey; + eccKeyAgreement.generateSecret(globalSelfPriKey, globalPeerPubKey, function (err, secret) { + if (err) { + console.error("ecdh error."); + return; + } + console.info("ecdh callback output is " + secret.data); + }); }); - }); + }) } ``` diff --git a/zh-cn/application-dev/security/huks-appendix.md b/zh-cn/application-dev/security/huks-appendix.md index 1a4e617a098266e85399656e88b3dab4261dfdc9..17375d29547456c2b7139fbe7401dc42a068b1f6 100644 --- a/zh-cn/application-dev/security/huks-appendix.md +++ b/zh-cn/application-dev/security/huks-appendix.md @@ -50,7 +50,7 @@ | ECC/SHA1
ECC/SHA224 | 8+ | |否| | ECC/SHA256
ECC/SHA384
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+ | |否| diff --git a/zh-cn/application-dev/task-management/work-scheduler-dev-guide.md b/zh-cn/application-dev/task-management/work-scheduler-dev-guide.md index f98f682fe5ce9792071103e460adf78129383c3f..d8e227f4c5423214146078003b07b9ba4bbb71fe 100644 --- a/zh-cn/application-dev/task-management/work-scheduler-dev-guide.md +++ b/zh-cn/application-dev/task-management/work-scheduler-dev-guide.md @@ -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}`); } diff --git a/zh-cn/application-dev/windowmanager/application-window-stage.md b/zh-cn/application-dev/windowmanager/application-window-stage.md index 6a8c67a9c395620bd8660db34559e795ab2f31c7..209481afbeb2873152d3e096d620ba99bdce3e66 100644 --- a/zh-cn/application-dev/windowmanager/application-window-stage.md +++ b/zh-cn/application-dev/windowmanager/application-window-stage.md @@ -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 { diff --git a/zh-cn/release-notes/OpenHarmony-1-0.md b/zh-cn/release-notes/OpenHarmony-1-0.md index 10935823396f1044c333f60e313b6c7f965eccb6..a9f5e60b8a285f77957135220da52eb4dc736307 100755 --- a/zh-cn/release-notes/OpenHarmony-1-0.md +++ b/zh-cn/release-notes/OpenHarmony-1-0.md @@ -1,4 +1,4 @@ -# OpenHarmony 1.0(2020-09-10) +# OpenHarmony 1.0(2020-09-10)(停止维护) ## 版本概述 @@ -35,4 +35,4 @@ repo sync -c ```shell git clone https://gitee.com/openharmony/manifest.git -b master -``` \ No newline at end of file +``` diff --git a/zh-cn/release-notes/OpenHarmony-1-1-0-LTS.md b/zh-cn/release-notes/OpenHarmony-1-1-0-LTS.md index 3c26f84f6e6b535c0b41f40abfa65467a9c1c9cf..88f2ac06e7f41279dad244c994b9362f2012ee5f 100755 --- a/zh-cn/release-notes/OpenHarmony-1-1-0-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-1-1-0-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony 1.1.0 LTS(2021-04-01) +# OpenHarmony 1.1.0 LTS(2021-04-01)(停止维护) ## 版本概述 diff --git a/zh-cn/release-notes/OpenHarmony-1-1-1-LTS.md b/zh-cn/release-notes/OpenHarmony-1-1-1-LTS.md index 31eeea9bde4d857f6f9ad4a0c515ee2051cecb18..2a8ab607f2e7c5e204dd947784064496cfb4e1ea 100755 --- a/zh-cn/release-notes/OpenHarmony-1-1-1-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-1-1-1-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony 1.1.1 LTS(2021-06-22) +# OpenHarmony 1.1.1 LTS(2021-06-22)(停止维护) ## 版本概述 diff --git a/zh-cn/release-notes/OpenHarmony-v1-1-3-LTS.md b/zh-cn/release-notes/OpenHarmony-v1-1-3-LTS.md index 06220f8a394909e0599b45be324bea2416c0c3b8..acab8de1d8383896cd57a26873ecc879047fc739 100644 --- a/zh-cn/release-notes/OpenHarmony-v1-1-3-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-v1-1-3-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony v1.1.3 LTS +# OpenHarmony v1.1.3 LTS (停止维护) ## 版本概述 diff --git a/zh-cn/release-notes/OpenHarmony-v1-1-4-LTS.md b/zh-cn/release-notes/OpenHarmony-v1-1-4-LTS.md index f12df131aa6cec6c96bdc526ea47f89dffd65386..8965da787ff93a3cb63e59cde2c50368aeb83134 100644 --- a/zh-cn/release-notes/OpenHarmony-v1-1-4-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-v1-1-4-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony 1.1.4 LTS +# OpenHarmony 1.1.4 LTS (停止维护) ## 版本概述 diff --git a/zh-cn/release-notes/OpenHarmony-v1.1.2-LTS.md b/zh-cn/release-notes/OpenHarmony-v1.1.2-LTS.md index 69048b3421fe3c5b6e2740135534e1e338a17e71..ca3c8d336f2c17ee3b0f6cff7316df2190ef0801 100644 --- a/zh-cn/release-notes/OpenHarmony-v1.1.2-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-v1.1.2-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony v1.1.2 LTS +# OpenHarmony v1.1.2 LTS (停止维护) ## 版本概述 diff --git a/zh-cn/release-notes/OpenHarmony-v1.1.5-LTS.md b/zh-cn/release-notes/OpenHarmony-v1.1.5-LTS.md index 0dfc9e23fa0c16514f8f74c9b214a371b4c4e66c..627b7c1ff3bd48f7e2902c613d9eb4a2e4f29316 100644 --- a/zh-cn/release-notes/OpenHarmony-v1.1.5-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-v1.1.5-LTS.md @@ -1,4 +1,4 @@ -# OpenHarmony 1.1.5 LTS +# OpenHarmony 1.1.5 LTS (停止维护) ## 版本概述 diff --git a/zh-cn/release-notes/OpenHarmony-v3.1.2-release.md b/zh-cn/release-notes/OpenHarmony-v3.1.2-release.md index c65099937519384a18c9911814ad5b5d5149635e..48e9fb91a17a869302a1004405e54209a9742a1c 100644 --- a/zh-cn/release-notes/OpenHarmony-v3.1.2-release.md +++ b/zh-cn/release-notes/OpenHarmony-v3.1.2-release.md @@ -87,8 +87,8 @@ repo forall -c 'git lfs pull' | Hi3516标准系统解决方案(二进制) | 3.1.2 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 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 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 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 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 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 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 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 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 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) | diff --git a/zh-cn/release-notes/OpenHarmony-v3.1.3-release.md b/zh-cn/release-notes/OpenHarmony-v3.1.3-release.md index 47b48ac3385903392c30a14f651ecdd58817bfe6..5eddc0ec5a2560960e797ce5f0abced24a440bf1 100644 --- a/zh-cn/release-notes/OpenHarmony-v3.1.3-release.md +++ b/zh-cn/release-notes/OpenHarmony-v3.1.3-release.md @@ -77,7 +77,7 @@ repo forall -c 'git lfs pull' | -------- | -------- | -------- | -------- | | 全量代码(标准、轻量和小型系统) | 3.1.3 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 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 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 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 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 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 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) | diff --git a/zh-cn/release-notes/OpenHarmony-v3.1.7-release.md b/zh-cn/release-notes/OpenHarmony-v3.1.7-release.md new file mode 100644 index 0000000000000000000000000000000000000000..fc672fff5a3c3ac050d73a70ede5997cd6b86edd --- /dev/null +++ b/zh-cn/release-notes/OpenHarmony-v3.1.7-release.md @@ -0,0 +1,156 @@ +# OpenHarmony 3.1.7 Release + + +## 版本概述 + +当前版本在OpenHarmony 3.1.6 Release的基础上,修复了内存泄漏及linux kernel等开源组件的安全漏洞,增强了系统安全性。修复了部分系统稳定性的issue,增强了系统稳定性。更新配套的SDK版本。 + + +## 配套关系 + + **表1** 版本软件和工具配套关系 + +| 软件 | 版本 | 备注 | +| ------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| OpenHarmony | 3.1.7 Release | NA | +| Full SDK | Ohos_sdk_full 3.1.13.5 (API Version 8 Relese) | 面向OEM厂商提供,包含了需要使用系统权限的系统接口。
使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 | +| Public SDK | Ohos_sdk_public 3.1.13.5 (API Version 8 Release) | 面向应用开发者提供,不包含需要使用系统权限的系统接口。
DevEco Studio 3.0 Beta4版本起,通过DevEco Studio获取的SDK默认为Public SDK。 | +| HUAWEI DevEco Studio(可选) | 3.1 Preview for OpenHarmony | OpenHarmony应用开发推荐使用。 | +| HUAWEI DevEco Device Tool(可选) | 3.0 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 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 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 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 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 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 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 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 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 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 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))
新建卡片推包到rk版,将卡片添加到桌面,长按桌面卡片,弹出服务卡片和移除按钮的同时也打开了应用([I5YB1O](https://gitee.com/openharmony/applications_hap/issues/I5YB1O))
通过工具测出CPPCrash问题([I65H83](https://gitee.com/openharmony/applications_permission_manager/issues/I65H83))
通过工具测出CPPCrash问题([I65TVW](https://gitee.com/openharmony/applications_permission_manager/issues/I65TVW))
Launcher 反复点击recent 按钮会出现内存泄漏([I67SRG](https://gitee.com/openharmony/xts_acts/issues/I67SRG)) | +| 媒体子系统 | 打开图库应用,选择相册页签,点击相机,高概率闪退值桌面([I5QUSZ](https://gitee.com/openharmony/applications_hap/issues/I5QUSZ))
通过工具测出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 diff --git a/zh-cn/release-notes/Readme.md b/zh-cn/release-notes/Readme.md index de2478b990ec99ec4eeb16ad5117796ad1baee82..01ccb35c2358f600ea31658dc200c256b22bb6b2 100644 --- a/zh-cn/release-notes/Readme.md +++ b/zh-cn/release-notes/Readme.md @@ -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)