diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..729f30574951c4eb8d70941a7597f799c0c8e40f --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.nativecase", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..104ce575da3b9134d26e8265cc11252d8d7b4e22 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NativeCase" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..338e5b0bc22082e0ffcc7121c2ed3897a3ddccb0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.md b/README.md index a6cb98d6769fee96a8b3355a3b6b740967325fff..ecf94da34b8fc84eb71c6d8a60d2afbe19564911 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,67 @@ -# NativeCase +# 实现ArkTS与Native交互功能 -#### 介绍 -本示例主要介绍如何实现ArkTS与Native C++层交互开发。主要包含以下两个主题:Native侧回调ArkTS函数和Native子线程与UI主线程通信。Native侧回调ArkTS函数分别使用同步任务Callback、异步任务Callback以及异步任务Promise三种方式实现;Native子线程与UI主线程通信分别使用线程安全函数和LibUV异步库两种方式实现。 +### 简介 -#### 软件架构 -软件架构说明 +本Codelab主要介绍如何实现ArkTS与Native C++层交互开发。主要包含以下两个主题:Native侧回调ArkTS函数和Native子线程与UI主线程通信。Native侧回调ArkTS函数分别使用同步任务Callback、异步任务Callback以及异步任务Promise三种方式实现;Native子线程与UI主线程通信分别使用线程安全函数和LibUV异步库两种方式实现。 +### 效果预览 -#### 安装教程 +![](screenshots/device/native_case.gif) -1. xxxx -2. xxxx -3. xxxx +### 使用说明 -#### 使用说明 +在主页面中点击对应按钮会分别跳转到不同场景的页面。在每个场景页面中都包含了一个信息展示区域和一个按钮,点击按钮会调用接口将相关信息显示到信息展示区域上。 -1. xxxx -2. xxxx -3. xxxx +### 工程结构 -#### 参与贡献 +``` +├──entry/src/main/cpp // C++代码区 +│ ├──AsyncCallback // 异步Callback方式回调 +│ │ ├──AsyncCallback.cpp +│ │ └──AsyncCallback.h +│ ├──AsyncPromise // 异步Promise方式回调 +│ │ ├──AsyncPromise.cpp +│ │ └──AsyncPromise.h +│ ├──LibUvCase // LibUV异步库方式通信 +│ │ ├──LibUvCase.cpp +│ │ └──LibUvCase.h +│ ├──SyncCallback // 同步Callback方式回调 +│ │ ├──SyncCallback.cpp +│ │ └──SyncCallback.h +│ ├──ThreadSafeCase // 线程安全函数方式通信 +│ │ ├──ThreadSafeCase.cpp +│ │ └──ThreadSafeCase.h +│ ├──types +│ │ └──libentry // C++接口导出 +│ │ ├──Index.d.ts +│ │ └──oh-package.json5 +│ ├──CMakeLists.txt // Cmake配置文件 +│ └──napi_init.cpp // Native侧接口映射 +├──entry/src/main/ets // ArkTS代码区 +│ ├──entryability +│ │ └──EntryAbility.ets +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets +│ ├──pages +│ │ ├──Index.ets // 主页面 +│ │ ├──SubMainThreadCom.ets // Native侧回调ArkTS函数页面 +│ │ └──SyncAndAsyncWork.ets // Native子线程与UI主线程通信页面 +│ └──view +│ └──TitleComponent.ets // 标题组件 +└──entry/src/main/resources // 应用资源文件 +``` -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +### 相关权限 +**不涉及** -#### 特技 +### 参考资料 -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +**不涉及** + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:华为手机。 +2. HarmonyOS系统:HarmonyOS 5.0.0 Release及以上。 +3. DevEco Studio版本:DevEco Studio 5.0.0 Release及以上。 +4. HarmonyOS SDK版本:HarmonyOS 5.0.0 Release SDK及以上。 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1e69556b3411622cb2e87a87389653bb34f1b148 --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,41 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..38a942ea7b79b6174e2e3cfa4eedd335750c29d7 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,38 @@ +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "arm64-v8a", + "x86_64" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + } + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..54cb066266f9993f5a023f2ac5a8dfc5d2574643 --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/entry/src/main/cpp/AsyncCallback/AsyncCallback.cpp b/entry/src/main/cpp/AsyncCallback/AsyncCallback.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9acfe8563ba239bab5860cdc6e2212ab67e8aba7 --- /dev/null +++ b/entry/src/main/cpp/AsyncCallback/AsyncCallback.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "AsyncCallback.h" +#include + +extern size_t g_contextLen; + +napi_value AsyncCallback::AsyncCallbackRead(napi_env env, napi_callback_info info) { + size_t argc = 3; + napi_value args[3] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + auto asyncContext = new CallbackData(); + + size_t fileNameSize; + napi_get_value_string_utf8(env, args[0], asyncContext->fileNameBuf, sizeof(asyncContext->fileNameBuf), + &fileNameSize); + + asyncContext->resMgr = OH_ResourceManager_InitNativeResourceManager(env, args[1]); + napi_create_reference(env, args[2], 1, &asyncContext->callbackRef); + + napi_value asyncWorkName = nullptr; + napi_create_string_utf8(env, "asyncWorkCallback", NAPI_AUTO_LENGTH, &asyncWorkName); + + napi_create_async_work(env, nullptr, asyncWorkName, ExecuteCB, CompleteCB, asyncContext, &asyncContext->asyncWork); + + napi_queue_async_work(env, asyncContext->asyncWork); + return nullptr; +}; +void AsyncCallback::ExecuteCB(napi_env env, void *data) { + CallbackData *asyncContext = reinterpret_cast(data); + + RawFile *rawFile = OH_ResourceManager_OpenRawFile(asyncContext->resMgr, asyncContext->fileNameBuf); + + std::unique_ptr fileData = std::make_unique(g_contextLen); + + long offset = 0; + while (OH_ResourceManager_GetRawFileRemainingLength(rawFile) > 0) { + OH_ResourceManager_ReadRawFile(rawFile, fileData.get() + offset, 100); + offset += 100; + } + + OH_ResourceManager_CloseRawFile(rawFile); + OH_ResourceManager_ReleaseNativeResourceManager(asyncContext->resMgr); + + char *temp = fileData.get(); + asyncContext->result = temp; +}; +void AsyncCallback::CompleteCB(napi_env env, napi_status status, void *data) { + CallbackData *asyncContext = static_cast(data); + + napi_value callback = nullptr; + napi_get_reference_value(env, asyncContext->callbackRef, &callback); + + napi_value contents; + napi_create_string_utf8(env, asyncContext->result.c_str(), NAPI_AUTO_LENGTH, &contents); + + napi_value res; + napi_call_function(env, nullptr, callback, 1, &contents, &res); + + napi_delete_reference(env, asyncContext->callbackRef); + napi_delete_async_work(env, asyncContext->asyncWork); + delete asyncContext; +}; \ No newline at end of file diff --git a/entry/src/main/cpp/AsyncCallback/AsyncCallback.h b/entry/src/main/cpp/AsyncCallback/AsyncCallback.h new file mode 100644 index 0000000000000000000000000000000000000000..bea8d1db0550e568aac61c6593e08adc049e4367 --- /dev/null +++ b/entry/src/main/cpp/AsyncCallback/AsyncCallback.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVECASE_ASYNCCALLBACK_H +#define NATIVECASE_ASYNCCALLBACK_H +#include "napi/native_api.h" +#include "rawfile/raw_file_manager.h" +#include +class AsyncCallback { +public: + struct CallbackData { + napi_async_work asyncWork = nullptr; + napi_ref callbackRef = nullptr; + char fileNameBuf[256] = {}; + NativeResourceManager *resMgr = nullptr; + std::string result = ""; + }; + + static napi_value AsyncCallbackRead(napi_env env, napi_callback_info info); + static void ExecuteCB(napi_env env, void *data); + static void CompleteCB(napi_env env, napi_status status, void *data); +}; +#endif // NATIVECASE_ASYNCCALLBACK_H diff --git a/entry/src/main/cpp/AsyncPromise/AsyncPromise.cpp b/entry/src/main/cpp/AsyncPromise/AsyncPromise.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e4dacae4225725d82335ae8b117164d31cdd0447 --- /dev/null +++ b/entry/src/main/cpp/AsyncPromise/AsyncPromise.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "AsyncPromise.h" +#include +extern size_t g_contextLen; + +napi_value AsyncPromise::AsyncPromiseRead(napi_env env, napi_callback_info info) { + size_t argc = 2; + napi_value args[2] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + napi_value promise = nullptr; + + auto asyncContext = new PromiseData(); + napi_create_promise(env, &asyncContext->deferred, &promise); + + size_t fileNameSize; + napi_get_value_string_utf8(env, args[0], asyncContext->fileNameBuf, sizeof(asyncContext->fileNameBuf), + &fileNameSize); + + asyncContext->resMgr = OH_ResourceManager_InitNativeResourceManager(env, args[1]); + + napi_value asyncWorkName = nullptr; + napi_create_string_utf8(env, "asyncWorkPromise", NAPI_AUTO_LENGTH, &asyncWorkName); + + napi_create_async_work(env, nullptr, asyncWorkName, ExecuteCB, CompleteCB, asyncContext, &asyncContext->asyncWork); + + napi_queue_async_work(env, asyncContext->asyncWork); + return promise; +}; +void AsyncPromise::ExecuteCB(napi_env env, void *data) { + PromiseData *asyncContext = reinterpret_cast(data); + + RawFile *rawFile = OH_ResourceManager_OpenRawFile(asyncContext->resMgr, asyncContext->fileNameBuf); + + std::unique_ptr fileData = std::make_unique(g_contextLen); + + long offset = 0; + while (OH_ResourceManager_GetRawFileRemainingLength(rawFile) > 0) { + OH_ResourceManager_ReadRawFile(rawFile, fileData.get() + offset, 100); + offset += 100; + } + OH_ResourceManager_CloseRawFile(rawFile); + OH_ResourceManager_ReleaseNativeResourceManager(asyncContext->resMgr); + + char *temp = fileData.get(); + asyncContext->result = temp; + +}; +void AsyncPromise::CompleteCB(napi_env env, napi_status status, void *data) { + PromiseData *asyncContext = reinterpret_cast(data); + + napi_value contents; +// napi_create_string_utf8(env, asyncContext->result, NAPI_AUTO_LENGTH, &contents); + napi_create_string_utf8(env, asyncContext->result.c_str(), NAPI_AUTO_LENGTH, &contents); + + if (contents != nullptr) { + napi_resolve_deferred(env, asyncContext->deferred, contents); + } else { + napi_reject_deferred(env, asyncContext->deferred, contents); + } + + napi_delete_async_work(env, asyncContext->asyncWork); + delete asyncContext; +}; \ No newline at end of file diff --git a/entry/src/main/cpp/AsyncPromise/AsyncPromise.h b/entry/src/main/cpp/AsyncPromise/AsyncPromise.h new file mode 100644 index 0000000000000000000000000000000000000000..5c5bf5a6b382cea6896fc329ecbed89dc8dfc21a --- /dev/null +++ b/entry/src/main/cpp/AsyncPromise/AsyncPromise.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVECASE_ASYNCPROMISE_H +#define NATIVECASE_ASYNCPROMISE_H +#include "napi/native_api.h" +#include "rawfile/raw_file_manager.h" +#include + +class AsyncPromise { +public: + struct PromiseData { + napi_async_work asyncWork = nullptr; + napi_deferred deferred = nullptr; + char fileNameBuf[256] = {}; + NativeResourceManager *resMgr = nullptr; + std::string result = ""; + }; + + static napi_value AsyncPromiseRead(napi_env env, napi_callback_info info); + static void ExecuteCB(napi_env env, void *data); + static void CompleteCB(napi_env env, napi_status status, void *data); +}; +#endif //NATIVECASE_ASYNCPROMISE_H diff --git a/entry/src/main/cpp/CMakeLists.txt b/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ceae65a10cfc49a2a3caaec83e4fdda88e95fe34 --- /dev/null +++ b/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,15 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NativeCase) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp SyncCallback/SyncCallback.cpp AsyncCallback/AsyncCallback.cpp AsyncPromise/AsyncPromise.cpp ThreadSafeCase/ThreadSafeCase.cpp LibUvCase/LibUvCase.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so librawfile.z.so libuv.so) \ No newline at end of file diff --git a/entry/src/main/cpp/LibUvCase/LibUvCase.cpp b/entry/src/main/cpp/LibUvCase/LibUvCase.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9bf79091be3f503c891e10c90472526eb13a3334 --- /dev/null +++ b/entry/src/main/cpp/LibUvCase/LibUvCase.cpp @@ -0,0 +1,86 @@ +// +// Created on 2025/1/10. +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "LibUvCase.h" +#include +extern int g_value; +static uv_loop_t *loop = nullptr; +static uv_async_t *async = nullptr; + +void LibUvCase::Async_handler(uv_async_t *handle) { + CallbackContext *context = reinterpret_cast(handle->data); + napi_handle_scope scope = nullptr; + napi_open_handle_scope(context->env, &scope); + if (scope == nullptr) { + napi_delete_reference(context->env, context->callbackRef); + delete context; + context = nullptr; + if (handle != nullptr) { + delete handle; + handle = nullptr; + } + return; + } + napi_value callback = nullptr; + napi_get_reference_value(context->env, context->callbackRef, &callback); + napi_value retArg; + napi_create_int32(context->env, g_value, &retArg); + napi_value result; + napi_call_function(context->env, nullptr, callback, 1, &retArg, &result); + napi_get_value_int32(context->env, result, &g_value); + napi_close_handle_scope(context->env, scope); + napi_delete_reference(context->env, context->callbackRef); + delete context; + context = nullptr; + uv_close((uv_handle_t *)async, [](uv_handle_t *handle) { delete (uv_async_t *)handle; }); +} + +void LibUvCase::CallbackUvWorkTest(CallbackContext *context) { + if (context == nullptr) { + return; + } + + async->data = reinterpret_cast(context); + uv_async_send(async); +} + +napi_value LibUvCase::LibUvCaseFun(napi_env env, napi_callback_info info) { + size_t argc = 1; + napi_value callback_function; + napi_get_cb_info(env, info, &argc, &callback_function, nullptr, nullptr); + + napi_valuetype valueType = napi_undefined; + napi_typeof(env, callback_function, &valueType); + if (valueType != napi_valuetype::napi_function) { + return nullptr; + } + + loop = uv_default_loop(); + async = new uv_async_t; + uv_async_init(loop, async, Async_handler); + + auto asyncContext = new CallbackContext(); + if (asyncContext == nullptr) { + return nullptr; + } + asyncContext->env = env; + napi_create_reference(env, callback_function, 1, &asyncContext->callbackRef); + std::thread caseThread(CallbackUvWorkTest, asyncContext); + caseThread.detach(); + uv_run(loop, UV_RUN_DEFAULT); + return nullptr; +} \ No newline at end of file diff --git a/entry/src/main/cpp/LibUvCase/LibUvCase.h b/entry/src/main/cpp/LibUvCase/LibUvCase.h new file mode 100644 index 0000000000000000000000000000000000000000..cde2f927ce8c72c79f9d57a6743f61733451cd8d --- /dev/null +++ b/entry/src/main/cpp/LibUvCase/LibUvCase.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVECASE_LIBUVCASE_H +#define NATIVECASE_LIBUVCASE_H +#include "napi/native_api.h" +#include + +class LibUvCase { +public: + struct CallbackContext { + napi_env env = nullptr; + napi_ref callbackRef = nullptr; + }; + + static void Async_handler(uv_async_t *handle); + static void CallbackUvWorkTest(CallbackContext *context); + static napi_value LibUvCaseFun(napi_env env, napi_callback_info info); +}; +#endif // NATIVECASE_LIBUVCASE_H diff --git a/entry/src/main/cpp/SyncCallback/SyncCallback.cpp b/entry/src/main/cpp/SyncCallback/SyncCallback.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8d0bb670c0008cbb1689fc98bf3772ff09d2f58a --- /dev/null +++ b/entry/src/main/cpp/SyncCallback/SyncCallback.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "SyncCallback.h" +#include + +/* + * Read the length of the text. + */ +size_t g_contextLen = 50000; + +napi_value SyncCallback::SyncCallbackRead(napi_env env, napi_callback_info info) { + size_t argc = 3; + napi_value args[3] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + size_t fileNameSize; + char fileNameBuf[256]; + napi_get_value_string_utf8(env, args[0], fileNameBuf, sizeof(fileNameBuf), &fileNameSize); + + NativeResourceManager *mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, args[1]); + + RawFile *rawFile = OH_ResourceManager_OpenRawFile(mNativeResMgr, fileNameBuf); + + std::unique_ptr fileData = std::make_unique(g_contextLen); + + long offset = 0; + while (OH_ResourceManager_GetRawFileRemainingLength(rawFile) > 0) { + OH_ResourceManager_ReadRawFile(rawFile, fileData.get() + offset, 100); + offset += 100; + } + + OH_ResourceManager_CloseRawFile(rawFile); + OH_ResourceManager_ReleaseNativeResourceManager(mNativeResMgr); + napi_value contents; + napi_create_string_utf8(env, fileData.get(), NAPI_AUTO_LENGTH, &contents); + + napi_value res = nullptr; + napi_call_function(env, nullptr, args[2], 1, &contents, &res); + return nullptr; +} \ No newline at end of file diff --git a/entry/src/main/cpp/SyncCallback/SyncCallback.h b/entry/src/main/cpp/SyncCallback/SyncCallback.h new file mode 100644 index 0000000000000000000000000000000000000000..274ac6ce17e21f01d8ad8849031eaecab4db5fbe --- /dev/null +++ b/entry/src/main/cpp/SyncCallback/SyncCallback.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVECASE_SYNCCALLBACK_H +#define NATIVECASE_SYNCCALLBACK_H +#include "napi/native_api.h" +#include "rawfile/raw_file_manager.h" +class SyncCallback { +public: + static napi_value SyncCallbackRead(napi_env env, napi_callback_info info); +}; +#endif // NATIVECASE_SYNCCALLBACK_H diff --git a/entry/src/main/cpp/ThreadSafeCase/ThreadSafeCase.cpp b/entry/src/main/cpp/ThreadSafeCase/ThreadSafeCase.cpp new file mode 100644 index 0000000000000000000000000000000000000000..25855b928dafbf6c02ecf2519c964627869a2e67 --- /dev/null +++ b/entry/src/main/cpp/ThreadSafeCase/ThreadSafeCase.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ThreadSafeCase.h" +#include + +/* + * calculation result. + */ +int g_value = 0; + +static napi_threadsafe_function tsFn = nullptr; + +void ThreadSafeCase::SubThread(CallbackContext *asyncContext) { + if (asyncContext == nullptr) { + return; + } + napi_acquire_threadsafe_function(tsFn); + napi_call_threadsafe_function(tsFn, asyncContext, napi_tsfn_nonblocking); + napi_release_threadsafe_function(tsFn, napi_tsfn_release); +} + +void ThreadSafeCase::ThreadSafeCallJs(napi_env env, napi_value js_callBack, void *context, void *data) { + CallbackContext *argContext = reinterpret_cast(data); + if (argContext != nullptr) { + napi_get_reference_value(env, argContext->callbackRef, &js_callBack); + } else { + return; + } + + napi_valuetype valueType = napi_undefined; + napi_typeof(env, js_callBack, &valueType); + if (valueType != napi_valuetype::napi_function) { + napi_delete_reference(env, argContext->callbackRef); + delete argContext; + argContext = nullptr; + return; + } + + napi_value argv; + napi_create_int32(env, g_value, &argv); + napi_value result = nullptr; + napi_call_function(env, nullptr, js_callBack, 1, &argv, &result); + napi_get_value_int32(env, result, &g_value); + napi_delete_reference(env, argContext->callbackRef); + delete argContext; + argContext = nullptr; +} + +napi_value ThreadSafeCase::ThreadSafeCaseFun(napi_env env, napi_callback_info info) { + size_t argc = 1; + napi_value js_callback; + napi_value workName; + napi_get_cb_info(env, info, &argc, &js_callback, nullptr, nullptr); + + napi_valuetype valueType = napi_undefined; + napi_typeof(env, js_callback, &valueType); + if (valueType != napi_valuetype::napi_function) { + return nullptr; + } + + napi_create_string_utf8(env, "ThreadSafeCase", NAPI_AUTO_LENGTH, &workName); + + napi_create_threadsafe_function(env, nullptr, nullptr, workName, 0, 1, nullptr, nullptr, nullptr, ThreadSafeCallJs, + &tsFn); + + auto asyncContext = new CallbackContext(); + asyncContext->env = env; + napi_create_reference(env, js_callback, 1, &asyncContext->callbackRef); + + std::thread t(SubThread, asyncContext); + t.detach(); + return nullptr; +} diff --git a/entry/src/main/cpp/ThreadSafeCase/ThreadSafeCase.h b/entry/src/main/cpp/ThreadSafeCase/ThreadSafeCase.h new file mode 100644 index 0000000000000000000000000000000000000000..118e9ee3db124eda037b6e557553fb6f76600445 --- /dev/null +++ b/entry/src/main/cpp/ThreadSafeCase/ThreadSafeCase.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVECASE_THREADSAFECASE_H +#define NATIVECASE_THREADSAFECASE_H +#include "napi/native_api.h" +class ThreadSafeCase { +public: + struct CallbackContext { + napi_env env = nullptr; + napi_ref callbackRef = nullptr; + }; + + static void SubThread(CallbackContext *asyncContext); + static void ThreadSafeCallJs(napi_env env, napi_value js_callBack, void *context, void *data); + static napi_value ThreadSafeCaseFun(napi_env env, napi_callback_info info); +}; +#endif // NATIVECASE_THREADSAFECASE_H diff --git a/entry/src/main/cpp/napi_init.cpp b/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..854cd3c2058e1d400403c31a1dbf5c204d9c6e30 --- /dev/null +++ b/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" +#include "./SyncCallback/SyncCallback.h" +#include "./AsyncCallback/AsyncCallback.h" +#include "./AsyncPromise/AsyncPromise.h" +#include "./ThreadSafeCase/ThreadSafeCase.h" +#include "./LibUvCase/LibUvCase.h" +extern int g_value; + +static napi_value Destroy(napi_env env, napi_callback_info info) { + g_value = 0; + return nullptr; +}; + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"syncCallbackRead", nullptr, SyncCallback::SyncCallbackRead, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"asyncCallbackRead", nullptr, AsyncCallback::AsyncCallbackRead, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"asyncPromiseRead", nullptr, AsyncPromise::AsyncPromiseRead, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"threadSafeCaseFun", nullptr, ThreadSafeCase::ThreadSafeCaseFun, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"libUvCaseFun", nullptr, LibUvCase::LibUvCaseFun, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"destroy", nullptr, Destroy, nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } diff --git a/entry/src/main/cpp/types/libentry/Index.d.ts b/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..86132e2c9926c714c96f55b9381e906eba4a7aba --- /dev/null +++ b/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { resourceManager } from '@kit.LocalizationKit' + +export const syncCallbackRead: (fileName: string, resMgr: resourceManager.ResourceManager, callback: object) => void; + +export const asyncCallbackRead: (fileName: string, resMgr: resourceManager.ResourceManager, callback: object) => void; + +export const asyncPromiseRead: (fileName: string, resMgr: resourceManager.ResourceManager) => Promise; + +export const threadSafeCaseFun: (work: object) => void; + +export const libUvCaseFun: (work: object) => void; + +export const destroy: () => void; \ No newline at end of file diff --git a/entry/src/main/cpp/types/libentry/oh-package.json5 b/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ea410725a8826704d061021d98cf02aa76cd8016 --- /dev/null +++ b/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..f33d10bf4a9babe18fede2dad978abb436ae740f --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; \ No newline at end of file diff --git a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..ad022a94f8e396457dc11dc34d68cc848d9c1cdd --- /dev/null +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e25c2f21d5e2ec9658bce6a60220a384188f9ad --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { SubMainThreadCom } from './SubMainThreadCom'; +import { SyncAndAsyncWork } from './SyncAndAsyncWork'; + +@Entry +@Component +struct Index { + @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack(); + + @Builder + PageMap(name: string) { + if (name === 'SyncAndAsyncWork') { + SyncAndAsyncWork(); + } else if (name === 'SubMainThreadCom') { + SubMainThreadCom(); + } else { + Index(); + } + } + + build() { + Navigation(this.pageInfos) { + Column() { + Text($r('app.string.sample_title')) + .width('100%') + .height(56) + .fontSize(30) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Bold) + .margin({ top: 64 }) + + Blank(); + + Button($r('app.string.work_button')) + .width('100%') + .fontWeight(500) + .fontSize(16) + .margin({ top: 12 }) + .onClick(() => { + this.pageInfos.pushPath({ name: 'SyncAndAsyncWork' }); + }) + + Button($r('app.string.thread_com_button')) + .width('100%') + .fontWeight(500) + .fontSize(16) + .margin({ top: 12 }) + .onClick(() => { + this.pageInfos.pushPath({ name: 'SubMainThreadCom' }); + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.End) + .padding({ left: 16, right: 16, bottom: 16}) + } + .hideTitleBar(true) + .mode(NavigationMode.Stack) + .backgroundColor($r('app.color.background_color')) + .navDestination(this.PageMap) + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) + } +} diff --git a/entry/src/main/ets/pages/SubMainThreadCom.ets b/entry/src/main/ets/pages/SubMainThreadCom.ets new file mode 100644 index 0000000000000000000000000000000000000000..09fd248d7319f38d5783c183d2e83c48f23771f7 --- /dev/null +++ b/entry/src/main/ets/pages/SubMainThreadCom.ets @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { promptAction } from '@kit.ArkUI'; +import testNapi from 'libentry.so'; +import { TitleComponent } from '../view/TitleComponent'; + +@Component +export struct SubMainThreadCom { + @Consume('pageInfos') pageInfos: NavPathStack; + @State value: number = 0; + private message: ResourceStr = $r('app.string.calculation_text_desc'); + + work: Function = (param: number) => { + param += 30; + this.value = param; + return param; + } + + aboutToDisappear(): void { + testNapi.destroy(); + } + + build() { + NavDestination() { + Column() { + Text(this.message) + .fontSize(14) + .width('100%') + .textAlign(TextAlign.Start) + .fontColor(Color.Black) + .opacity(0.6) + .fontWeight(500) + .margin({ top: 24 }) + TextInput({ text: JSON.stringify(this.value) }) + .fontSize(16) + .focusable(false) + .fontColor(Color.Black) + .backgroundColor(Color.White) + .fontWeight(FontWeight.Normal) + .margin({ top: 12 }) + + Blank(); + + Button($r('app.string.thread_safe_func_button')) + .width('100%') + .onClick(() => { + testNapi.threadSafeCaseFun(this.work); + promptAction.showToast({ + message: $r('app.string.thread_com_toast'), + duration: 2000 + }) + }) + Button($r('app.string.lib_uv_method_button')) + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + testNapi.libUvCaseFun(this.work); + promptAction.showToast({ + message: $r('app.string.lib_uv_toast'), + duration: 2000 + }) + }) + } + .justifyContent(FlexAlign.End) + .padding({ left: 16, right: 16, bottom: 16 }) + .width('100%') + .height('100%') + } + .backgroundColor($r('app.color.background_color')) + .title(TitleComponent($r('app.string.thread_com_title'), $r('app.string.thread_com_title_desc'))) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/SyncAndAsyncWork.ets b/entry/src/main/ets/pages/SyncAndAsyncWork.ets new file mode 100644 index 0000000000000000000000000000000000000000..7805af522fed3d242204aaa67d242927a45b29cc --- /dev/null +++ b/entry/src/main/ets/pages/SyncAndAsyncWork.ets @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { resourceManager } from '@kit.LocalizationKit'; +import testNapi from 'libentry.so'; +import { TitleComponent } from '../view/TitleComponent' + +@Component +export struct SyncAndAsyncWork { + @Consume('pageInfos') pageInfos: NavPathStack; + private resMgr: resourceManager.ResourceManager = getContext().resourceManager; + @State message: ResourceStr = $r('app.string.read_text_desc'); + + build() { + NavDestination() { + Column() { + TextArea({ text: this.message }) + .fontSize(16) + .focusable(false) + .fontWeight(400) + .height('30%') + .borderRadius(16) + .backgroundColor(Color.White) + .margin({ top: 16 }) + + Blank(); + + Button($r('app.string.sync_callback_button')) + .width('100%') + .fontWeight(500) + .fontSize(16) + .onClick(() => { + testNapi.syncCallbackRead('SyncCallback.txt', this.resMgr, (res: string) => { + this.message = res; + }) + }) + + Button($r('app.string.async_callback_button')) + .width('100%') + .fontWeight(500) + .fontSize(16) + .margin({ top: 12 }) + .onClick(() => { + testNapi.asyncCallbackRead('AsyncCallback.txt', this.resMgr, (res: string) => { + this.message = res; + }) + }) + + Button($r('app.string.async_promise_button')) + .width('100%') + .fontWeight(500) + .fontSize(16) + .margin({ top: 12 }) + .onClick(() => { + testNapi.asyncPromiseRead('AsyncPromise.txt', this.resMgr).then((res: string) => { + this.message = res; + }); + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.End) + .padding({ left: 16, right: 16, bottom: 16 }) + } + .backgroundColor($r('app.color.background_color')) + .title(TitleComponent($r('app.string.work_title'), $r('app.string.work_title_desc'))) + } +} diff --git a/entry/src/main/ets/view/TitleComponent.ets b/entry/src/main/ets/view/TitleComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..18991d25726bd68be81e3e93e06f16fabd390914 --- /dev/null +++ b/entry/src/main/ets/view/TitleComponent.ets @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* + * General Title Component. + */ +@Builder +export function TitleComponent(title: ResourceStr, description: ResourceStr) { + Column() { + Text(title) + .fontSize(20) + .height(27) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .fontWeight(FontWeight.Bold) + Text(description) + .fontSize(14) + .height(19) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .fontColor(Color.Black) + .opacity(0.6) + .fontWeight(400) + .margin({ top: 2 }) + } + .margin({ left: 8, top: 4, bottom: 4 }) + .alignItems(HorizontalAlign.Start) +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ad219d733f6afa5ea07f85f580208b08cc3b9041 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..ab6f86207f76e10081964ee25d8c46d969e8b0d5 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,12 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "background_color", + "value": "#F1F3F5" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..74b5102901a74514f2c83286f8d383a5e0eb16ba --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,80 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Native Case" + }, + { + "name": "sample_title", + "value": "Native Sample Code" + }, + { + "name": "work_button", + "value": "Synchronous/Asynchronous Tasks" + }, + { + "name": "work_title", + "value": "Synchronous/Asynchronous Tasks" + }, + { + "name": "work_title_desc", + "value": "Read file information" + }, + { + "name": "calculation_text_desc", + "value": "Value calculation result:" + }, + { + "name": "thread_com_button", + "value": "Communication Between Native Child Threads and Main Thread" + }, + { + "name": "thread_com_title", + "value": "Communication Between Native Child Threads and Main Thread" + }, + { + "name": "thread_com_title_desc", + "value": "Call back the UI main thread in the native child thread" + }, + { + "name": "thread_com_toast", + "value": "Add 30 in invocation via a thread-safe function" + }, + { + "name": "lib_uv_toast", + "value": "Add 30 in invocation via libuv" + }, + { + "name": "read_text_desc", + "value": "The file reading result is displayed here." + }, + { + "name": "sync_callback_button", + "value": "Synchronous Callback" + }, + { + "name": "async_callback_button", + "value": "Asynchronous Callback" + }, + { + "name": "async_promise_button", + "value": "Asynchronous Promise" + }, + { + "name": "thread_safe_func_button", + "value": "Invoke via Thread-Safe Function" + }, + { + "name": "lib_uv_method_button", + "value": "Invoke via libuv" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/background.png b/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/entry/src/main/resources/base/media/background.png differ diff --git a/entry/src/main/resources/base/media/foreground.png b/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.png differ diff --git a/entry/src/main/resources/base/media/layered_image.json b/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/entry/src/main/resources/dark/element/color.json b/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..74b5102901a74514f2c83286f8d383a5e0eb16ba --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,80 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Native Case" + }, + { + "name": "sample_title", + "value": "Native Sample Code" + }, + { + "name": "work_button", + "value": "Synchronous/Asynchronous Tasks" + }, + { + "name": "work_title", + "value": "Synchronous/Asynchronous Tasks" + }, + { + "name": "work_title_desc", + "value": "Read file information" + }, + { + "name": "calculation_text_desc", + "value": "Value calculation result:" + }, + { + "name": "thread_com_button", + "value": "Communication Between Native Child Threads and Main Thread" + }, + { + "name": "thread_com_title", + "value": "Communication Between Native Child Threads and Main Thread" + }, + { + "name": "thread_com_title_desc", + "value": "Call back the UI main thread in the native child thread" + }, + { + "name": "thread_com_toast", + "value": "Add 30 in invocation via a thread-safe function" + }, + { + "name": "lib_uv_toast", + "value": "Add 30 in invocation via libuv" + }, + { + "name": "read_text_desc", + "value": "The file reading result is displayed here." + }, + { + "name": "sync_callback_button", + "value": "Synchronous Callback" + }, + { + "name": "async_callback_button", + "value": "Asynchronous Callback" + }, + { + "name": "async_promise_button", + "value": "Asynchronous Promise" + }, + { + "name": "thread_safe_func_button", + "value": "Invoke via Thread-Safe Function" + }, + { + "name": "lib_uv_method_button", + "value": "Invoke via libuv" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/AsyncCallback.txt b/entry/src/main/resources/rawfile/AsyncCallback.txt new file mode 100644 index 0000000000000000000000000000000000000000..460c38a8cedd1158fe7bfbdc52a1472338d9ff06 --- /dev/null +++ b/entry/src/main/resources/rawfile/AsyncCallback.txt @@ -0,0 +1 @@ +In asynchronous Callback mode, the application side needs to pass the callback function. After the application side invokes the native interface, the native side executes the service logic asynchronously, without blocking the application side. For example, if the application side needs to read a file, in the asynchronous mode, the application side does not wait for file reading from the native side to complete but continue to run. \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/AsyncPromise.txt b/entry/src/main/resources/rawfile/AsyncPromise.txt new file mode 100644 index 0000000000000000000000000000000000000000..afb9c17d9e35448afaee0adc8d215be784ad8f5c --- /dev/null +++ b/entry/src/main/resources/rawfile/AsyncPromise.txt @@ -0,0 +1 @@ +In asynchronous promise mode, the application side needs to pass the callback function. After the application side invokes the native interface, the native side also asynchronously executes the service logic, without blocking the application side. \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/SyncCallback.txt b/entry/src/main/resources/rawfile/SyncCallback.txt new file mode 100644 index 0000000000000000000000000000000000000000..28910688aa1b6fd39cd4707498c44df29b7a2e9a --- /dev/null +++ b/entry/src/main/resources/rawfile/SyncCallback.txt @@ -0,0 +1 @@ +During synchronous tasks development, the main thread on the ArkTS application side waits for the calculation results, which is sent from the native side through the Ark engine. During this process, the Native code and the ArkTS application code run on the ArkTS main thread. For example, if the application side needs to read a file, in the synchronous mode, the application side waits until the file reading on the native side is complete before running. \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c9636e801b9d4466ccccc5fba2d8dc5080f0ce74 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,80 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Native Case" + }, + { + "name": "sample_title", + "value": "Native 示例代码" + }, + { + "name": "work_button", + "value": "同步/异步任务" + }, + { + "name": "work_title", + "value": "同步/异步任务" + }, + { + "name": "work_title_desc", + "value": "读取文件信息" + }, + { + "name": "thread_com_button", + "value": "Native子线程与主线程通信" + }, + { + "name": "thread_com_title", + "value": "Native子线程与主线程通信" + }, + { + "name": "thread_com_title_desc", + "value": "在Native子线程中回调UI主线程" + }, + { + "name": "thread_com_toast", + "value": "线程安全函数方式执行加30操作" + }, + { + "name": "lib_uv_toast", + "value": "LibUV异步库方式执行加30操作" + }, + { + "name": "read_text_desc", + "value": "此处显示文件读取结果!" + }, + { + "name": "calculation_text_desc", + "value": "Value计算结果:" + }, + { + "name": "sync_callback_button", + "value": "同步Callback方式" + }, + { + "name": "async_callback_button", + "value": "异步Callback方式" + }, + { + "name": "async_promise_button", + "value": "异步Promise方式" + }, + { + "name": "thread_safe_func_button", + "value": "线程安全函数方式调用" + }, + { + "name": "lib_uv_method_button", + "value": "LibUV异步库方式调用" + } + ] +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8bf916d4a165e0466c65bc49f58ab2e3c27e8931 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,8 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + } +} diff --git a/screenshots/device/native_case.gif b/screenshots/device/native_case.gif new file mode 100644 index 0000000000000000000000000000000000000000..3fc64d68d4899e1afbc870f50409340232a2b968 Binary files /dev/null and b/screenshots/device/native_case.gif differ