diff --git a/README.md b/README.md index 11c6dfc4e8ebc9faa4affa8022e29ac3a35b5efa..b6817298ac69443e2463b9b63c26a816a964bd4d 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 new file mode 100644 index 0000000000000000000000000000000000000000..1ba9cb7b08378485698691998eca3b8809f97fa3 --- /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 5.0.0 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 5.0.0 Release SDK or later. \ No newline at end of file