From b69cba06bc8d7c91b4c9b690b8c58efb202da96f Mon Sep 17 00:00:00 2001 From: Ryan <865833921@qq.com> Date: Sat, 22 Feb 2025 09:46:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=8B=B1=E6=96=87readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README_EN.md | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 README_EN.md diff --git a/README_EN.md b/README_EN.md new file mode 100644 index 0000000..6d5b635 --- /dev/null +++ b/README_EN.md @@ -0,0 +1,93 @@ +# Calling APIs Across HAR and HSP Modules on the Native Side + +### Overview + +This sample shows how to call APIs across HAR and HSP modules on the native side. It is used for large-scale app development, in which the native code directly calls APIs provided by other HAR and HSP modules. Through this sample, you can understand the file configuration and call logic for calling **Native** and **ArkTS** methods across HAR and HSP modules on the native side. + +### Preview + +![](screenshots/device/nativeCall.png) + + +How to Use + +1. Tap the first button to call the **Native** method. + +2. Tap the second button to call the **Native** method of the **staticModule** module. + +3. Tap the third button to call the **ArkTS** method of the **Har** module through the **Native** method of the **staticModule** module. + +4. Tap the fourth button to call the **Native** method of the **sharedModule** module. + +5. Tap the last button to call the **ArkTS** method of the **sharedModule** module through the **Native** method of the **sharedModule** module. + +Note: When running an app, you need to set **Deploy Multi Hap**. Tap **Edit Configuration** and select an entry. Tap **Deploy Multi Hap** and select **Deploy Multi Hap Packages**. + +### Project Directory +``` +├──entry/src/main // Native layer +│ ├──cpp +│ │ ├──types // Interfaces exposed by the native layer +│ │ │ └──libfile_access // Interfaces exposed to the UI layer +│ │ ├──CMakeLists.txt // Compilation entry +│ │ └──napi_init.cpp // Native file operation methods +│ └──ets // UI layer +│ ├──entryability // App entry +│ │ └──EntryAbility.ets +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets +│ ├──model +│ │ └──FileNameModel.ets +│ └──pages // Pages contained in the EntryAbility +│ └──Index.ets // Home page of the app +├──staticModule/src/main // HAR module +│ ├──cpp +│ │ ├──types // Interfaces exposed by the native layer +│ │ │ └──libfile_access // Interfaces exposed to the UI layer +│ │ ├──CMakeLists.txt // Compilation entry +│ │ ├──napi_har.cpp // Native methods provided by the HAR module +│ │ ├──napi_har.h // napi_har header file +│ │ └──napi_init.cpp +│ └──ets // UI layer +│ ├──components +│ │ └──MainPage.ets +│ └──utils +│ └──Util.ets // ArkTS methods +└──sharedModule/src/main // HSP module +├──cpp +│ ├──types // Interfaces exposed by the native layer +│ │ └──libfile_access // Interfaces exposed to the UI layer +│ ├──CMakeLists.txt // Compilation entry +│ ├──napi_hsp.cpp // Native methods provided by the HSP module +│ ├──napi_hsp.h // napi_hsp header file +│ └──napi_init.cpp +└──ets // UI layer +├──components +│ └──MainPage.ets +└──utils +└──Calc.ets // ArkTS methods + +``` +### How to Implement +* Create **staticModule** (HAR) and **sharedModule** (HSP) and configure the corresponding dependencies in **oh-package.json5** of **entry**. +* Create the **Native** method and its header file in the **staticModule** (HAR) and **sharedModule** (HSP), and configure the header file export in the **build-profile.json5** file of the modules. +* Reference the **ArkTS** method in the **staticModule** (HAR) and **sharedModule** (HSP) on the native side. +* Reference the **Native** method in the **staticModule** (HAR) and **sharedModule** (HSP) on the native side of **entry**. + +### Permissions + +N/A + +### Dependencies + +N/A + +### Constraints + +1. The sample is only supported on Huawei phones with standard systems. + +2. The HarmonyOS version must be HarmonyOS NEXT Developer Release or later. + +3. The DevEco Studio version must be DevEco Studio NEXT Developer Release or later. + +4. The HarmonyOS SDK version must be HarmonyOS NEXT Developer Release SDK or later. \ No newline at end of file -- Gitee From eb83098f827cf49aedf64762edf1157b8ffd1946 Mon Sep 17 00:00:00 2001 From: Ryan <865833921@qq.com> Date: Thu, 27 Feb 2025 14:31:42 +0800 Subject: [PATCH 2/2] =?UTF-8?q?readme=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++--- README_EN.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 11c6dfc..b681729 100644 --- a/README.md +++ b/README.md @@ -86,8 +86,8 @@ 1. 本示例仅支持标准系统上运行,支持设备:华为手机。 -2. HarmonyOS系统:HarmonyOS NEXT Developer Release及以上。 +2. HarmonyOS系统:HarmonyOS 5.0.0 Release及以上。 -3. DevEco Studio版本:DevEco Studio NEXT Developer Release及以上。 +3. DevEco Studio版本:DevEco Studio 5.0.0 Release及以上。 -4. HarmonyOS SDK版本:HarmonyOS NEXT Developer Release SDK及以上。 \ No newline at end of file +4. HarmonyOS SDK版本:HarmonyOS 5.0.0 Release SDK及以上。 \ No newline at end of file diff --git a/README_EN.md b/README_EN.md index 6d5b635..1ba9cb7 100644 --- a/README_EN.md +++ b/README_EN.md @@ -86,8 +86,8 @@ N/A 1. The sample is only supported on Huawei phones with standard systems. -2. The HarmonyOS version must be HarmonyOS NEXT Developer Release or later. +2. The HarmonyOS version must be HarmonyOS 5.0.0 Release or later. -3. The DevEco Studio version must be DevEco Studio NEXT Developer Release or later. +3. The DevEco Studio version must be DevEco Studio 5.0.0 Release or later. -4. The HarmonyOS SDK version must be HarmonyOS NEXT Developer Release SDK or later. \ No newline at end of file +4. The HarmonyOS SDK version must be HarmonyOS 5.0.0 Release SDK or later. \ No newline at end of file -- Gitee