diff --git a/AbilityKit/MetaCompetences/.gitignore b/AbilityKit/MetaCompetences/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/AbilityKit/MetaCompetences/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/AppScope/app.json5 b/AbilityKit/MetaCompetences/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..56d879ec40e0e441a8406aafe867c69186cdc4e8 --- /dev/null +++ b/AbilityKit/MetaCompetences/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * 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. + */ +{ + "app": { + "bundleName": "com.samples.MetaCompetences", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/AbilityKit/MetaCompetences/AppScope/resources/base/element/string.json b/AbilityKit/MetaCompetences/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c1ad6d8b0f9f8fd12f926f4a44569b63f6d360f9 --- /dev/null +++ b/AbilityKit/MetaCompetences/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MetaCompetences" + } + ] +} diff --git a/AbilityKit/MetaCompetences/AppScope/resources/base/media/background.png b/AbilityKit/MetaCompetences/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/AbilityKit/MetaCompetences/AppScope/resources/base/media/background.png differ diff --git a/AbilityKit/MetaCompetences/AppScope/resources/base/media/foreground.png b/AbilityKit/MetaCompetences/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/AbilityKit/MetaCompetences/AppScope/resources/base/media/foreground.png differ diff --git a/AbilityKit/MetaCompetences/AppScope/resources/base/media/layered_image.json b/AbilityKit/MetaCompetences/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/AbilityKit/MetaCompetences/AppScope/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/AbilityKit/MetaCompetences/README_zh.md b/AbilityKit/MetaCompetences/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..426a4d3861725e00b702db4d9e7d756247d79947 --- /dev/null +++ b/AbilityKit/MetaCompetences/README_zh.md @@ -0,0 +1,91 @@ +# 应用启动框架AppStartup + +### 介绍 + +应用启动时通常需要执行一系列初始化启动任务,如果将启动任务都放在HAP的UIAbility组件的onCreate生命周期中,那么只能在主线程中依次执行,不但影响应用的启动速度,而且当启动任务过多时,任务之间复杂的依赖关系还会使得代码难以维护。 + +AppStartup提供了一种应用启动方式,可以支持任务的异步启动。同时,通过在一个配置文件中统一设置多个启动任务的执行顺序以及依赖关系,使启动任务的代码更简洁、清晰、易维护。 + +### 运行机制 +启动框架支持以自动模式或手动模式执行启动任务,默认采用自动模式。在构造AbilityStage过程中开始加载开发者配置的启动任务,并执行自动模式的启动任务。开发者也可以在AbilityStage创建完后调用startupManager.run方法,执行手动模式的启动任务。 + +### 工程目录 +``` +entry/src/main/ +│ module.json5 # 模块核心配置(设备类型、系统能力、权限等) +│ +├─ cpp/ # Native层so源码目录 +│ │ CMakeLists.txt # C++编译配置脚本(控制so生成) +│ │ +│ └─ types/ # so类型定义(供ArkTS调用的接口声明) +│ +├─ ets/ # ArkTS业务代码目录(应用功能核心) +│ ├─ entryability/ # 应用启动入口(Ability组件) +│ │ └─ EntryAbility.ets # 主Ability,控制应用生命周期 +│ │ +│ ├─ entrybackupability/ # 备份能力(非必需,按需保留) +│ │ └─ EntryBackupAbility.ets +│ │ +│ ├─ pages/ # 页面组件目录(用户交互界面) +│ │ └─ Index.ets # 首页界面代码 +│ │ +│ └─ startup/ # AppStartup启动任务目录(启动流程控制) +│ +└─ resources/ # 模块资源目录(界面与业务依赖的资源) + └─ base/ + └─ profile/ # 配置文件(路由、启动任务等) + └─ startup_config.json # 启动任务配置(任务顺序、依赖等) + +``` + +### 关系图 +**图1** 启动任务依赖关系图 +![img_1.png](img_1.png) + +**图2** so预加载任务依赖关系图 +![img.png](img.png) + +注意:so和任务需自己进行相关配置,代码只做展示 + +### 使用说明 +1. 当前工程应用启动框架共包含6个启动任务,启动工程化会自动并发执行启动任务 +2. 001—004为自动任务,005.006为手动任务 + +### 具体实现 + +1. 在HAP的“resources/base/profile”路径下,新建启动框架配置文件。文件名可以自定义,本文以"startup_config.json"为例。 +2. 在module.json5配置文件的appStartup标签中,添加启动框架配置文件的索引。 +3. 在“ets/startup”路径下,创建启动参数配置文件。本例中的文件名为StartupConfig.ets。 +4. 在启动框架配置文件startup_config.json中,添加启动参数配置文件的相关信息。 +5. 在“ets/startup”路径下,依次创建启动任务文件。 +6. 在启动框架配置文件startup_config.json中,添加启动任务配置 +7. 创建so文件。 +8. 在启动框架配置文件startup_config.json中,添加预加载so任务配置。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:RK3568。 + +2.本示例已适配API version 10版本SDK,版本号:4.0.10.13。 + +3.本示例需要使用DevEco Studio 4.0 (Build Version: 4.0.0.600 构建 2023年10月17日)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Ability/Performance/MetaCompetence/ > .git/info/sparse-checkout +git remote add origin https://gitcode.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/build-profile.json5 b/AbilityKit/MetaCompetences/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1e8b118f7c00b90783f8cdc47d0b2235cc0dc3eb --- /dev/null +++ b/AbilityKit/MetaCompetences/build-profile.json5 @@ -0,0 +1,86 @@ +/* + * 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. + */ +{ + "app": { + "signingConfigs": [ + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "6.0.0(20)", + "compatibleSdkVersion": "6.0.0(20)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "nativeCompiler": "BiSheng", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "hsp1", + "srcPath": "./hsp1", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "hsp2", + "srcPath": "./hsp2", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "har1", + "srcPath": "./har1", + } + ] +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/code-linter.json5 b/AbilityKit/MetaCompetences/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5c4682f8164874ec7e9cb8f99ff8b3228ffbc126 --- /dev/null +++ b/AbilityKit/MetaCompetences/code-linter.json5 @@ -0,0 +1,46 @@ +/* + * 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. + */ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/build-profile.json5 b/AbilityKit/MetaCompetences/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..528494d151fe49cd020925a880db21599485a7c1 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/build-profile.json5 @@ -0,0 +1,59 @@ +/* + * 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. + */ +{ + "apiType": "stageMode", + "buildOption": { + "resOptions": { + "copyCodeResource": { + "enable": false + } + }, + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": ["arm64-v8a", "x86_64"] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/hvigorfile.ts b/AbilityKit/MetaCompetences/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8b117a17af3b2d7cb87a7680e29e2bb8ccd5b46 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * 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 { 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. */ +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/obfuscation-rules.txt b/AbilityKit/MetaCompetences/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/oh-package.json5 b/AbilityKit/MetaCompetences/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f792f2d8d3f18173b8e21a4ecd343dadfdc176a8 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/oh-package.json5 @@ -0,0 +1,30 @@ +/* + * 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. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry_001.so": "file:./src/main/cpp/types/libentry1", + "libentry_002.so": "file:./src/main/cpp/types/libentry2", + "libentry_003.so": "file:./src/main/cpp/types/libentry3", + "libentry_004.so": "file:./src/main/cpp/types/libentry4", + "libentry_005.so": "file:./src/main/cpp/types/libentry5", + "libentry_006.so": "file:./src/main/cpp/types/libentry6" + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/CMakeLists.txt b/AbilityKit/MetaCompetences/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..64866a9f5fa99a84ac1e426f25ae51a205b393c8 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,32 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(MetaCompetences) + +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_001 SHARED napi_init1.cpp) +add_library(entry_002 SHARED napi_init2.cpp) +add_library(entry_003 SHARED napi_init3.cpp) +add_library(entry_004 SHARED napi_init4.cpp) +add_library(entry_005 SHARED napi_init5.cpp) +add_library(entry_006 SHARED napi_init6.cpp) + + +target_link_libraries(entry_001 PUBLIC libace_napi.z.so entry_002 entry_003) + +target_link_libraries(entry_002 PUBLIC libace_napi.z.so entry_003 entry_004) + +target_link_libraries(entry_003 PUBLIC libace_napi.z.so entry_004) + +target_link_libraries(entry_004 PUBLIC libace_napi.z.so) + +target_link_libraries(entry_005 PUBLIC libace_napi.z.so entry_006) + +target_link_libraries(entry_006 PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init1.cpp b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4a6e38e6722dad22dba1ebda2d737c7e87c8d7d1 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init1.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ +#include "napi/native_api.h" + +static napi_value Add(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_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, 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_001", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init2.cpp b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..af55e2fb547ac98a741273ae02c038c20a38fd3e --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init2.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ +#include "napi/native_api.h" + +static napi_value Add(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_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, 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_002", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init3.cpp b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2e2ebe1a75b9739e5daae0843df657a65ebe9fe5 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init3.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ +#include "napi/native_api.h" + +static napi_value Add(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_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, 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_003", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init4.cpp b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init4.cpp new file mode 100644 index 0000000000000000000000000000000000000000..febd99bfcef9b306a9bc3ddfed07342504bc0581 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init4.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ +#include "napi/native_api.h" + +static napi_value Add(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_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, 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_004", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init5.cpp b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init5.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e6f35e0e2279728bacfcf34ac943cba5d24b2346 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init5.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ +#include "napi/native_api.h" + +static napi_value Add(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_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, 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_005", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init6.cpp b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init6.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b0fbfcb3be27320402d9b035754dfea9ac57a084 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/napi_init6.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ +#include "napi/native_api.h" + +static napi_value Add(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_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, 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_006", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry1/Index.d.ts b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry1/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13a34842c293a6773ab293fd9e206d13e0a18bb1 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry1/Index.d.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry1/oh-package.json5 b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry1/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0c627e92b8c6ce9cf1c57a1e667581242ff41746 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry1/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * 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. + */ +{ + "name": "libentry_001.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry2/Index.d.ts b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry2/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13a34842c293a6773ab293fd9e206d13e0a18bb1 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry2/Index.d.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry2/oh-package.json5 b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry2/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1cd7b67d725569da63ab62131a0d941118cf580a --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry2/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * 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. + */ +{ + "name": "libentry_002.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry3/Index.d.ts b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry3/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13a34842c293a6773ab293fd9e206d13e0a18bb1 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry3/Index.d.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry3/oh-package.json5 b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry3/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..263ab4daaf83e12674d7272cd85914e19cc76c12 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry3/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * 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. + */ +{ + "name": "libentry_003.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry4/Index.d.ts b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry4/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13a34842c293a6773ab293fd9e206d13e0a18bb1 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry4/Index.d.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry4/oh-package.json5 b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry4/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..82d9873bb634c6ca2b5072e7407ac7b7f73f0cb0 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry4/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * 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. + */ +{ + "name": "libentry_004.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry5/Index.d.ts b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry5/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13a34842c293a6773ab293fd9e206d13e0a18bb1 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry5/Index.d.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry5/oh-package.json5 b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry5/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0ce5b726a7a0072822abf1c68cd53c3bc654b3c2 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry5/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * 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. + */ +{ + "name": "libentry_005.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry6/Index.d.ts b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry6/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13a34842c293a6773ab293fd9e206d13e0a18bb1 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry6/Index.d.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry6/oh-package.json5 b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry6/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..464f22f93a784c48aa4c8fa23d47446f1a45e1aa --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/cpp/types/libentry6/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * 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. + */ +{ + "name": "libentry_006.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/ets/entryability/EntryAbility.ets b/AbilityKit/MetaCompetences/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..785f2fdee55fff28f81065144b6f70b442785081 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,75 @@ +/* + * 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. + */ +// [Start startup007] +import { AbilityConstant, UIAbility, Want , startupManager} from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +// [StartExclude startup007] +import { window } from '@kit.ArkUI'; +const DOMAIN = 0x0000; +// [EndExclude startup007] + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + let startParams = ['StartupTask_005', 'StartupTask_006']; + try { + startupManager.run(startParams).then(() => { + console.info(`StartupTest startupManager run then, startParams = ${JSON.stringify(startParams)}.`); + }).catch((error: BusinessError) => { + console.error(`StartupTest promise catch error, error = ${JSON.stringify(error)}.`); + console.error(`StartupTest promise catch error, startParams = ${JSON.stringify(startParams)}.`); + }) + } catch (error) { + let errMsg = (error as BusinessError).message; + let errCode = (error as BusinessError).code; + console.error(`Startup catch error, errCode= ${errCode}.`); + console.error(`Startup catch error, errMsg= ${errMsg}.`); + } + } + // [StartExclude startup007] + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } + // [EndExclude startup007] +} +// [End startup007] \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/AbilityKit/MetaCompetences/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * 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'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/ets/pages/Index.ets b/AbilityKit/MetaCompetences/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2196ccd0314af9fec6a4f6f3459b342410982f62 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,48 @@ +/* + * 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. + */ +// [Start startup008] +import { startupManager } from '@kit.AbilityKit'; + +@Entry +@Component +struct Index { + @State message: ResourceStr = $r('app.string.manual_mode'); + @State startParams1: Array = ['StartupTask_006']; + @State startParams2: Array = ['libentry_006']; + + build() { + RelativeContainer() { + Button(this.message) + .id('AppStartup') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .onClick(() => { + if (!startupManager.isStartupTaskInitialized('StartupTask_006') ) { // 判断是否已经完成初始化 + startupManager.run(this.startParams1); + } + if (!startupManager.isStartupTaskInitialized('libentry_006') ) { + startupManager.run(this.startParams2); + } + }) + .alignRules({ + center: {anchor: '__container__', align: VerticalAlign.Center}, + middle: {anchor: '__container__', align: HorizontalAlign.Center} + }) + } + .height('100%') + .width('100%') + } +} +// [End startup008] \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupConfig.ets b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupConfig.ets new file mode 100644 index 0000000000000000000000000000000000000000..46e43ace91e474803ab1851c9f5c59257bc70475 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupConfig.ets @@ -0,0 +1,53 @@ +/* + * 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. + */ +// [Start startup002] +// [Start startup009] +import { StartupConfig, StartupConfigEntry, StartupListener,Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +export default class MyStartupConfigEntry extends StartupConfigEntry { + // [StartExclude startup009] + onConfig() { + hilog.info(0x0000, 'testTag', `onConfig`); + let onCompletedCallback = (error: BusinessError) => { + hilog.info(0x0000, 'testTag', `onCompletedCallback`); + if (error) { + hilog.error(0x0000, 'testTag', 'onCompletedCallback: %{public}d, message: %{public}s', error.code, error.message); + } else { + hilog.info(0x0000, 'testTag', `onCompletedCallback: success.`); + } + }; + let startupListener: StartupListener = { + 'onCompleted': onCompletedCallback + }; + let config: StartupConfig = { + 'timeoutMs': 10000, + 'startupListener': startupListener + }; + return config; + } + // [EndExclude startup009] + // [StartExclude startup002] + onRequestCustomMatchRule(want: Want): string { + if (want?.parameters?.fromType == 'card') { + return 'ruleCard'; + } + return ''; + } + // [EndExclude startup002] +} +// [End startup009] +// [End startup002] \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_001.ets b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_001.ets new file mode 100644 index 0000000000000000000000000000000000000000..604e10a013f6923762ae068785806c0a0040def1 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_001.ets @@ -0,0 +1,35 @@ +/* + * 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. + */ +// [Start startup003] +import { StartupTask, common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@Sendable +export default class StartupTask001 extends StartupTask { + constructor() { + super(); + } + + async init(context: common.AbilityStageContext) { + hilog.info(0x0000, 'testTag', 'StartupTask_001 init.'); + return 'StartupTask_001'; + } + + onDependencyCompleted(dependence: string, result: Object): void { + hilog.info(0x0000, 'testTag', 'StartupTask_001 onDependencyCompleted, dependence: %{public}s, result: %{public}s', + dependence, JSON.stringify(result)); + } +} +// [End startup003] \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_002.ets b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_002.ets new file mode 100644 index 0000000000000000000000000000000000000000..38f8c467cba7e4e05b45b192491a2852b30d8273 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_002.ets @@ -0,0 +1,33 @@ +/* + * 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 { StartupTask, common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@Sendable +export default class StartupTask002 extends StartupTask { + constructor() { + super(); + } + + async init(context: common.AbilityStageContext) { + hilog.info(0x0000, 'testTag', 'StartupTask_002 init.'); + return 'StartupTask_002'; + } + + onDependencyCompleted(dependence: string, result: Object): void { + hilog.info(0x0000, 'testTag', 'StartupTask_002 onDependencyCompleted, dependence: %{public}s, result: %{public}s', + dependence, JSON.stringify(result)); + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_003.ets b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_003.ets new file mode 100644 index 0000000000000000000000000000000000000000..66ae55d299b8e7a01f247ef32291813118e19464 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_003.ets @@ -0,0 +1,33 @@ +/* + * 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 { StartupTask, common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@Sendable +export default class StartupTask003 extends StartupTask { + constructor() { + super(); + } + + async init(context: common.AbilityStageContext) { + hilog.info(0x0000, 'testTag', 'StartupTask_003 init.'); + return 'StartupTask_003'; + } + + onDependencyCompleted(dependence: string, result: Object): void { + hilog.info(0x0000, 'testTag', 'StartupTask_003 onDependencyCompleted, dependence: %{public}s, result: %{public}s', + dependence, JSON.stringify(result)); + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_004.ets b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_004.ets new file mode 100644 index 0000000000000000000000000000000000000000..5d08ebd551203a3b10dd88d5be0ef913a2295d09 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_004.ets @@ -0,0 +1,33 @@ +/* + * 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 { StartupTask, common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@Sendable +export default class StartupTask004 extends StartupTask { + constructor() { + super(); + } + + async init(context: common.AbilityStageContext) { + hilog.info(0x0000, 'testTag', 'StartupTask_004 init.'); + return 'StartupTask_004'; + } + + onDependencyCompleted(dependence: string, result: Object): void { + hilog.info(0x0000, 'testTag', 'StartupTask_004 onDependencyCompleted, dependence: %{public}s, result: %{public}s', + dependence, JSON.stringify(result)); + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_005.ets b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_005.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c7859d965cd2adb087b71044de9e6fa5e15b271 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_005.ets @@ -0,0 +1,33 @@ +/* + * 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 { StartupTask, common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@Sendable +export default class StartupTask005 extends StartupTask { + constructor() { + super(); + } + + async init(context: common.AbilityStageContext) { + hilog.info(0x0000, 'testTag', 'StartupTask_005 init.'); + return 'StartupTask_005'; + } + + onDependencyCompleted(dependence: string, result: Object): void { + hilog.info(0x0000, 'testTag', 'StartupTask_005 onDependencyCompleted, dependence: %{public}s, result: %{public}s', + dependence, JSON.stringify(result)); + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_006.ets b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_006.ets new file mode 100644 index 0000000000000000000000000000000000000000..e5f80c1f20dfc143ed854de4427990d4557e30aa --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/ets/startup/StartupTask_006.ets @@ -0,0 +1,33 @@ +/* + * 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 { StartupTask, common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@Sendable +export default class StartupTask006 extends StartupTask { + constructor() { + super(); + } + + async init(context: common.AbilityStageContext) { + hilog.info(0x0000, 'testTag', 'StartupTask_006 init.'); + return 'StartupTask_006'; + } + + onDependencyCompleted(dependence: string, result: Object): void { + hilog.info(0x0000, 'testTag', 'StartupTask_006 onDependencyCompleted, dependence: %{public}s, result: %{public}s', + dependence, JSON.stringify(result)); + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/module.json5 b/AbilityKit/MetaCompetences/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2500f6ebd305cbdad700e5be87f0618c43df1209 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/module.json5 @@ -0,0 +1,71 @@ +/* + * 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. + */ +// [Start startup001] +{ + "module": { + "name": "entry", + "type": "entry", + // [StartExclude startup001] + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default" + ], + // [EndExclude startup001] + "appStartup": "$profile:startup_config", // 启动框架的配置文件 + // [StartExclude startup001] + "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": [ + "ohos.want.action.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ], + // [EndExclude startup001] + } +} +// [End startup001] \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/resources/base/element/color.json b/AbilityKit/MetaCompetences/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/resources/base/element/float.json b/AbilityKit/MetaCompetences/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/AbilityKit/MetaCompetences/entry/src/main/resources/base/element/string.json b/AbilityKit/MetaCompetences/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a608af7abba949fa7d83b0c8ec9414504aeccfd7 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "manual_mode", + "value": "手动模式" + } + ] +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/resources/base/media/background.png b/AbilityKit/MetaCompetences/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/AbilityKit/MetaCompetences/entry/src/main/resources/base/media/background.png differ diff --git a/AbilityKit/MetaCompetences/entry/src/main/resources/base/media/foreground.png b/AbilityKit/MetaCompetences/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/AbilityKit/MetaCompetences/entry/src/main/resources/base/media/foreground.png differ diff --git a/AbilityKit/MetaCompetences/entry/src/main/resources/base/media/layered_image.json b/AbilityKit/MetaCompetences/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/AbilityKit/MetaCompetences/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/AbilityKit/MetaCompetences/entry/src/main/resources/base/media/startIcon.png b/AbilityKit/MetaCompetences/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/AbilityKit/MetaCompetences/entry/src/main/resources/base/media/startIcon.png differ diff --git a/AbilityKit/MetaCompetences/entry/src/main/resources/base/profile/backup_config.json b/AbilityKit/MetaCompetences/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/main/resources/base/profile/main_pages.json b/AbilityKit/MetaCompetences/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/AbilityKit/MetaCompetences/entry/src/main/resources/base/profile/startup_config.json b/AbilityKit/MetaCompetences/entry/src/main/resources/base/profile/startup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..055de23f0aec2038eacbf7bdf2d36350a25caea6 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/main/resources/base/profile/startup_config.json @@ -0,0 +1,120 @@ + +{ + "startupTasks": [ + { + "name": "StartupTask_001", + "srcEntry": "./ets/startup/StartupTask_001.ets", + "dependencies": [ + "StartupTask_002", + "StartupTask_003" + ], + "runOnThread": "taskPool", + "waitOnMainThread": false + }, + { + "name": "StartupTask_002", + "srcEntry": "./ets/startup/StartupTask_002.ets", + "dependencies": [ + "StartupTask_003", + "StartupTask_004" + ], + "runOnThread": "taskPool", + "waitOnMainThread": false + }, + { + "name": "StartupTask_003", + "srcEntry": "./ets/startup/StartupTask_003.ets", + "dependencies": [ + "StartupTask_004" + ], + "runOnThread": "taskPool", + "waitOnMainThread": false + }, + { + "name": "StartupTask_004", + "srcEntry": "./ets/startup/StartupTask_004.ets", + "runOnThread": "taskPool", + "waitOnMainThread": false, + "schedulerPhase": "preAbilityStageLoad", + "matchRules": { + "uris": [ + "test://com.example.startupdemo/notification" + ] + } + }, + { + "name": "StartupTask_005", + "srcEntry": "./ets/startup/StartupTask_005.ets", + "dependencies": [ + "StartupTask_006" + ], + "runOnThread": "mainThread", + "waitOnMainThread": true, + "excludeFromAutoStart": true + }, + { + "name": "StartupTask_006", + "srcEntry": "./ets/startup/StartupTask_006.ets", + "runOnThread": "mainThread", + "waitOnMainThread": false, + "excludeFromAutoStart": true, + "matchRules": { + "uris": [ + "test://com.example.startupdemo/notification" + ], + "customization": [ + "ruleCard" + ] + } + } + ], + "appPreloadHintStartupTasks": [ + { + "name": "libentry_001", + "srcEntry": "libentry_001.so", + "dependencies": [ + "libentry_002", + "libentry_003" + ], + "runOnThread": "taskPool" + }, + { + "name": "libentry_002", + "srcEntry": "libentry_002.so", + "dependencies": [ + "libentry_003", + "libentry_004" + ], + "runOnThread": "taskPool" + }, + { + "name": "libentry_003", + "srcEntry": "libentry_003.so", + "dependencies": [ + "libentry_004" + ], + "runOnThread": "taskPool" + }, + { + "name": "libentry_004", + "srcEntry": "libentry_004.so", + "runOnThread": "taskPool" + }, + { + "name": "libentry_005", + "srcEntry": "libentry_005.so", + "dependencies": [ + "libentry_006" + ], + "runOnThread": "taskPool", + "excludeFromAutoStart": true + }, + { + "name": "libentry_006", + "srcEntry": "libentry_006.so", + "runOnThread": "taskPool", + "excludeFromAutoStart": true + } + ], + "configEntry": "./ets/startup/StartupConfig.ets" +} diff --git a/AbilityKit/MetaCompetences/entry/src/main/resources/dark/element/color.json b/AbilityKit/MetaCompetences/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/AbilityKit/MetaCompetences/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/AbilityKit/MetaCompetences/entry/src/mock/Libentry.mock.ets b/AbilityKit/MetaCompetences/entry/src/mock/Libentry.mock.ets new file mode 100644 index 0000000000000000000000000000000000000000..82fa70b5693ddab96d237d2d17d943d866b61465 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/mock/Libentry.mock.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ +const NativeMock: Record = { + 'add': (a: number, b: number) => { + return a + b; + }, +}; + +export default NativeMock; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/mock/mock-config.json5 b/AbilityKit/MetaCompetences/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..98b0ae79f0090e1fc381d54c959fb32c9f7563f4 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/mock/mock-config.json5 @@ -0,0 +1,19 @@ +/* + * 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. + */ +{ + "libentry.so": { + "source": "src/mock/Libentry.mock.ets" + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/ohosTest/ets/test/Ability.test.ets b/AbilityKit/MetaCompetences/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..141eb908484c8f498b4161f24fe3c4c9ae8e0c65 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,64 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { startupManager, Want } from '@kit.AbilityKit'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { BusinessError } from '@kit.BasicServicesKit'; + +let want: Want = { + bundleName: 'com.samples.MetaCompetences', + abilityName: 'EntryAbility', +} + +function sleep(time: number) { + return new Promise((resolve: Function) => setTimeout(resolve, time)); +} + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('MetaCompetences_StartAbility_0100', 0, async (done:Function) => { + let startParams = ['StartupTask_005', 'StartupTask_006']; + try{ + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator(); + await abilityDelegatorRegistry.startAbility(want); + done(); + }catch(e){ + expect(false).assertTrue(); + done(); + } + }) + }) +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/ohosTest/ets/test/List.test.ets b/AbilityKit/MetaCompetences/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c64e0b06938d246ce044186d4b2d02b500a89e14 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/ohosTest/module.json5 b/AbilityKit/MetaCompetences/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..59667117c86b64ab9863f7b382c435ae4a3c32fa --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/ohosTest/module.json5 @@ -0,0 +1,25 @@ +/* + * 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. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/AbilityKit/MetaCompetences/entry/src/test/List.test.ets b/AbilityKit/MetaCompetences/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/entry/src/test/LocalUnit.test.ets b/AbilityKit/MetaCompetences/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/AbilityKit/MetaCompetences/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/.gitignore b/AbilityKit/MetaCompetences/har1/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/Index.ets b/AbilityKit/MetaCompetences/har1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..35860d4eac351bcd9cda3537b5d24b18db8316be --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/Index.ets @@ -0,0 +1,15 @@ +/* + * 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. + */ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/AbilityKit/MetaCompetences/har1/build-profile.json5 b/AbilityKit/MetaCompetences/har1/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..abbf158309fcaf2b6e1b8b582ea5b783cf8a8f6c --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * 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. + */ +{ + "apiType": "stageMode", + "buildOption": { + "resOptions": { + "copyCodeResource": { + "enable": false + } + }, + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", // CMake脚本路径 + "abiFilters": ["arm64-v8a", "x86_64"] // 编译目标架构 + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/AbilityKit/MetaCompetences/har1/consumer-rules.txt b/AbilityKit/MetaCompetences/har1/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/AbilityKit/MetaCompetences/har1/hvigorfile.ts b/AbilityKit/MetaCompetences/har1/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..0ebbf7729c020d9937096de85d9ba2e494669076 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * 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 { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/obfuscation-rules.txt b/AbilityKit/MetaCompetences/har1/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/oh-package.json5 b/AbilityKit/MetaCompetences/har1/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7dd2f6eeb8814c06a01a817c667b6f3b08583fa0 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * 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. + */ +{ + "name": "har1", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "libhar1_01.so": "file:./src/main/cpp/types/libhar1" + } +} diff --git a/AbilityKit/MetaCompetences/har1/src/main/cpp/CMakeLists.txt b/AbilityKit/MetaCompetences/har1/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..8077129c66588eef5792c8f50418949bca669c0e --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/main/cpp/CMakeLists.txt @@ -0,0 +1,16 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(MetaCompetences) + +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(har1_01 SHARED napi_init1.cpp) + +target_link_libraries(har1_01 PUBLIC libace_napi.z.so) diff --git a/AbilityKit/MetaCompetences/har1/src/main/cpp/napi_init1.cpp b/AbilityKit/MetaCompetences/har1/src/main/cpp/napi_init1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0b88813aef9d552559be169552a8758e6c364b58 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/main/cpp/napi_init1.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ +#include "napi/native_api.h" + +static napi_value Add(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_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, 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 = "har1_01", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule1(void) +{ + napi_module_register(&demoModule); +} diff --git a/AbilityKit/MetaCompetences/har1/src/main/cpp/types/libhar1/Index.d.ts b/AbilityKit/MetaCompetences/har1/src/main/cpp/types/libhar1/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13a34842c293a6773ab293fd9e206d13e0a18bb1 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/main/cpp/types/libhar1/Index.d.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/src/main/cpp/types/libhar1/oh-package.json5 b/AbilityKit/MetaCompetences/har1/src/main/cpp/types/libhar1/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e81bc5684eb5f7fa6f7e2113cd4aa121bd159911 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/main/cpp/types/libhar1/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * 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. + */ +{ + "name": "libhar1_01.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/src/main/ets/components/MainPage.ets b/AbilityKit/MetaCompetences/har1/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..3e169a1165a8dacc1972c86d06d3982ea652ccf7 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/main/ets/components/MainPage.ets @@ -0,0 +1,33 @@ +/* + * 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. + */ +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/AbilityKit/MetaCompetences/har1/src/main/ets/startup/HAR1_Task_01.ets b/AbilityKit/MetaCompetences/har1/src/main/ets/startup/HAR1_Task_01.ets new file mode 100644 index 0000000000000000000000000000000000000000..840391ccde02143a4464c9724a6edd2243a25c36 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/main/ets/startup/HAR1_Task_01.ets @@ -0,0 +1,33 @@ +/* + * 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 { StartupTask, common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@Sendable +export default class HAR2Task01 extends StartupTask { + constructor() { + super(); + } + + async init(context: common.AbilityStageContext) { + hilog.info(0x0000, 'testTag', 'HAR2_Task_01 init.'); + return 'HAR2_Task_01'; + } + + onDependencyCompleted(dependence: string, result: Object): void { + hilog.info(0x0000, 'testTag', 'HAR2_Task_01 onDependencyCompleted, dependence: %{public}s, result: %{public}s', + dependence, JSON.stringify(result)); + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/src/main/ets/startup/StartupConfig.ets b/AbilityKit/MetaCompetences/har1/src/main/ets/startup/StartupConfig.ets new file mode 100644 index 0000000000000000000000000000000000000000..f0cdc606e7328cba45df4565b9c383c498c79dc0 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/main/ets/startup/StartupConfig.ets @@ -0,0 +1,41 @@ +/* + * 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. + */ +// [Start startup_config_0100] +import { StartupConfig, StartupConfigEntry, StartupListener } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +export default class MyStartupConfigEntry extends StartupConfigEntry { + onConfig() { + hilog.info(0x0000, 'testTag', `onConfig`); + let onCompletedCallback = (error: BusinessError) => { + hilog.info(0x0000, 'testTag', `onCompletedCallback`); + if (error) { + hilog.error(0x0000, 'testTag', 'onCompletedCallback: %{public}d, message: %{public}s', error.code, error.message); + } else { + hilog.info(0x0000, 'testTag', `onCompletedCallback: success.`); + } + }; + let startupListener: StartupListener = { + 'onCompleted': onCompletedCallback + }; + let config: StartupConfig = { + 'timeoutMs': 10000, + 'startupListener': startupListener + }; + return config; + } +} +// [End startup_config_0100] \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/src/main/module.json5 b/AbilityKit/MetaCompetences/har1/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5c02ca1a1f60dfdf98982e05762724e2f8746271 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/main/module.json5 @@ -0,0 +1,30 @@ +/* + * 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. + */ +// [Start startup006] +{ + "module": { + "name": "har1", + "type": "har", + // [StartExclude startup006] + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + // [EndExclude startup006] + "appStartup": "$profile:startup_config", // 启动框架的配置文件 + } +} +// [End startup006] \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/src/main/resources/base/element/float.json b/AbilityKit/MetaCompetences/har1/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/AbilityKit/MetaCompetences/har1/src/main/resources/base/element/string.json b/AbilityKit/MetaCompetences/har1/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/AbilityKit/MetaCompetences/har1/src/main/resources/base/profile/startup_config.json b/AbilityKit/MetaCompetences/har1/src/main/resources/base/profile/startup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..3afce6cd2e508d592199e9583a70a3a8801501c4 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/main/resources/base/profile/startup_config.json @@ -0,0 +1,25 @@ +{ + "startupTasks": [ + { + "name": "HSP1_Task_01", + "srcEntry": "./ets/startup/HAR1_Task_01.ets", + "dependencies": [ + "HSP2_Task_01" + ], + "runOnThread": "taskPool", + "waitOnMainThread": false, + "excludeFromAutoStart": true + } + ], + "appPreloadHintStartupTasks": [ + { + "name": "libhar1_01", + "srcEntry": "libhar1_01.so", + "dependencies": [ + "libhsp2_01" + ], + "runOnThread": "taskPool", + "excludeFromAutoStart": true + } + ] +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/src/ohosTest/ets/test/Ability.test.ets b/AbilityKit/MetaCompetences/har1/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f30942b81554a399e89aa253c7089eca4f8d8d1 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,49 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/src/ohosTest/ets/test/List.test.ets b/AbilityKit/MetaCompetences/har1/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c64e0b06938d246ce044186d4b2d02b500a89e14 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/src/ohosTest/module.json5 b/AbilityKit/MetaCompetences/har1/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5c6f72d827cf45a04bbaae675c813dd353084571 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/ohosTest/module.json5 @@ -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. + */ +{ + "module": { + "name": "har1_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/AbilityKit/MetaCompetences/har1/src/test/List.test.ets b/AbilityKit/MetaCompetences/har1/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/har1/src/test/LocalUnit.test.ets b/AbilityKit/MetaCompetences/har1/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/AbilityKit/MetaCompetences/har1/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/.gitignore b/AbilityKit/MetaCompetences/hsp1/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/Index.ets b/AbilityKit/MetaCompetences/hsp1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..057894506c99a71e2b28e614a10d31ce8ea8cfe5 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/Index.ets @@ -0,0 +1,15 @@ +/* + * 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. + */ +export { add } from './src/main/ets/utils/Calc'; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/build-profile.json5 b/AbilityKit/MetaCompetences/hsp1/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6aa37298cb55a9f4c94c6b5d56fa9fab963090f8 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * 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. + */ +{ + "apiType": "stageMode", + "buildOption": { + "resOptions": { + "copyCodeResource": { + "enable": false + } + }, + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", // CMake脚本路径 + "abiFilters": ["arm64-v8a", "x86_64"] // 编译目标架构 + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/consumer-rules.txt b/AbilityKit/MetaCompetences/hsp1/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/AbilityKit/MetaCompetences/hsp1/hvigorfile.ts b/AbilityKit/MetaCompetences/hsp1/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..3685a087a33c2e63c17d4e98660f489c3f31aa25 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * 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 { hspTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/obfuscation-rules.txt b/AbilityKit/MetaCompetences/hsp1/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/oh-package.json5 b/AbilityKit/MetaCompetences/hsp1/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6b3d51f04dd0751b539c1515c294f1688143bdd8 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/oh-package.json5 @@ -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. + */ +{ + "name": "hsp1", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "packageType": "InterfaceHar", + "dependencies": { + "libhsp1_01.so": "file:./src/main/cpp/types/libhsp11", + "libhsp1_02.so": "file:./src/main/cpp/types/libhsp12" + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/cpp/CMakeLists.txt b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..33dfca17f0a466a2b5f96b7b2bd590e04211bd3a --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/CMakeLists.txt @@ -0,0 +1,18 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(MetaCompetences) + +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(hsp1_01 SHARED napi_init1.cpp) +add_library(hsp1_02 SHARED napi_init2.cpp) + +target_link_libraries(hsp1_01 PUBLIC libace_napi.z.so) +target_link_libraries(hsp1_02 PUBLIC libace_napi.z.so) diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/cpp/napi_init1.cpp b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/napi_init1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bc361f293a487d6e2822c96b4beae1cd4030e824 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/napi_init1.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ +#include "napi/native_api.h" + +static napi_value Add(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_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, 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 = "hsp1_01", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule1(void) +{ + napi_module_register(&demoModule); +} diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/cpp/napi_init2.cpp b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/napi_init2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c0231ad0920020c8e79b356f51467ec1786e5992 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/napi_init2.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ +#include "napi/native_api.h" + +static napi_value Add(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_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, 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 = "hsp1_02", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule2(void) +{ + napi_module_register(&demoModule); +} diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp11/Index.d.ts b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp11/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13a34842c293a6773ab293fd9e206d13e0a18bb1 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp11/Index.d.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp11/oh-package.json5 b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp11/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9a4b5580b9662c9533961fafe50b30a99f89e1ed --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp11/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * 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. + */ +{ + "name": "libhsp1_01.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp12/Index.d.ts b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp12/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13a34842c293a6773ab293fd9e206d13e0a18bb1 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp12/Index.d.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp12/oh-package.json5 b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp12/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5b8fa577aaed0486c5d35b5ac06bcd9b32750222 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/cpp/types/libhsp12/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * 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. + */ +{ + "name": "libhsp1_02.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/ets/pages/Index.ets b/AbilityKit/MetaCompetences/hsp1/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8f83477a373839476b4da2220d55f6e3e9b2d0aa --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/ets/pages/Index.ets @@ -0,0 +1,34 @@ +/* + * 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. + */ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/ets/startup/HSP1_Task_01.ets b/AbilityKit/MetaCompetences/hsp1/src/main/ets/startup/HSP1_Task_01.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb9a2bebbd7247eed17d29ccb1419028b2ef6f36 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/ets/startup/HSP1_Task_01.ets @@ -0,0 +1,33 @@ +/* + * 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 { StartupTask, common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@Sendable +export default class HSP1Task01 extends StartupTask { + constructor() { + super(); + } + + async init(context: common.AbilityStageContext) { + hilog.info(0x0000, 'testTag', 'HSP1_Task_01 init.'); + return 'HSP1_Task_01'; + } + + onDependencyCompleted(dependence: string, result: Object): void { + hilog.info(0x0000, 'testTag', 'HSP1_Task_01 onDependencyCompleted, dependence: %{public}s, result: %{public}s', + dependence, JSON.stringify(result)); + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/ets/startup/HSP1_Task_02.ets b/AbilityKit/MetaCompetences/hsp1/src/main/ets/startup/HSP1_Task_02.ets new file mode 100644 index 0000000000000000000000000000000000000000..21110f2e0e4b76d0881e7916dcf017911d021370 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/ets/startup/HSP1_Task_02.ets @@ -0,0 +1,33 @@ +/* + * 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 { StartupTask, common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@Sendable +export default class HSP1Task02 extends StartupTask { + constructor() { + super(); + } + + async init(context: common.AbilityStageContext) { + hilog.info(0x0000, 'testTag', 'HSP1_Task_02 init.'); + return 'HSP1_Task_02'; + } + + onDependencyCompleted(dependence: string, result: Object): void { + hilog.info(0x0000, 'testTag', 'HSP1_Task_02 onDependencyCompleted, dependence: %{public}s, result: %{public}s', + dependence, JSON.stringify(result)); + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/ets/startup/StartupConfig.ets b/AbilityKit/MetaCompetences/hsp1/src/main/ets/startup/StartupConfig.ets new file mode 100644 index 0000000000000000000000000000000000000000..f0cdc606e7328cba45df4565b9c383c498c79dc0 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/ets/startup/StartupConfig.ets @@ -0,0 +1,41 @@ +/* + * 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. + */ +// [Start startup_config_0100] +import { StartupConfig, StartupConfigEntry, StartupListener } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +export default class MyStartupConfigEntry extends StartupConfigEntry { + onConfig() { + hilog.info(0x0000, 'testTag', `onConfig`); + let onCompletedCallback = (error: BusinessError) => { + hilog.info(0x0000, 'testTag', `onCompletedCallback`); + if (error) { + hilog.error(0x0000, 'testTag', 'onCompletedCallback: %{public}d, message: %{public}s', error.code, error.message); + } else { + hilog.info(0x0000, 'testTag', `onCompletedCallback: success.`); + } + }; + let startupListener: StartupListener = { + 'onCompleted': onCompletedCallback + }; + let config: StartupConfig = { + 'timeoutMs': 10000, + 'startupListener': startupListener + }; + return config; + } +} +// [End startup_config_0100] \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/ets/utils/Calc.ets b/AbilityKit/MetaCompetences/hsp1/src/main/ets/utils/Calc.ets new file mode 100644 index 0000000000000000000000000000000000000000..a5a468e6949ac73107a40372b2aeeec63227ac6b --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/ets/utils/Calc.ets @@ -0,0 +1,17 @@ +/* + * 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. + */ +export function add(a: number, b: number) { + return a + b; +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/module.json5 b/AbilityKit/MetaCompetences/hsp1/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..df1ec0e73589c600f08f20a2f61f419a8a57db8a --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/module.json5 @@ -0,0 +1,32 @@ +/* + * 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. + */ +// [Start startup004] +{ + "module": { + "name": "hsp1", + "type": "shared", + // [StartExclude startup004] + "description": "$string:shared_desc", + // [EndExclude startup004] + "appStartup": "$profile:startup_config", // 启动框架的配置文件 + // [StartExclude startup004] + "deviceTypes": [ + ], + "deliveryWithInstall": true, + "pages": "$profile:main_pages", + // [EndExclude startup004] + } +} +// [End startup004] \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/element/float.json b/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/element/string.json b/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..98e1d8a84b3d8539ea33e79fe2ac593a05d23bb4 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "shared_desc", + "value": "description" + } + ] +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/profile/main_pages.json b/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/profile/startup_config.json b/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/profile/startup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..596c0293264934ffc88753dbe3514d3aedbc5263 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/main/resources/base/profile/startup_config.json @@ -0,0 +1,27 @@ +{ + "startupTasks": [ + { + "name": "HSP1_Task_01", + "srcEntry": "./ets/startup/HSP1_Task_01.ets", + "dependencies": [ + "HSP1_Task_02", + "HAR1_Task_01" + ], + "runOnThread": "taskPool", + "waitOnMainThread": false, + "excludeFromAutoStart": true + } + ], + "appPreloadHintStartupTasks": [ + { + "name": "libhsp1_01", + "srcEntry": "libhsp1_01.so", + "dependencies": [ + "libhsp1_02", + "libhar1_01" + ], + "runOnThread": "taskPool", + "excludeFromAutoStart": true + } + ] +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/ohosTest/ets/test/Ability.test.ets b/AbilityKit/MetaCompetences/hsp1/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f30942b81554a399e89aa253c7089eca4f8d8d1 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,49 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/ohosTest/ets/test/List.test.ets b/AbilityKit/MetaCompetences/hsp1/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c64e0b06938d246ce044186d4b2d02b500a89e14 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/ohosTest/module.json5 b/AbilityKit/MetaCompetences/hsp1/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..533f3781d61a7fe1fab7c1423fcec5c76532eeb9 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/ohosTest/module.json5 @@ -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. + */ +{ + "module": { + "name": "hsp1_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/test/List.test.ets b/AbilityKit/MetaCompetences/hsp1/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp1/src/test/LocalUnit.test.ets b/AbilityKit/MetaCompetences/hsp1/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp1/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/.gitignore b/AbilityKit/MetaCompetences/hsp2/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/Index.ets b/AbilityKit/MetaCompetences/hsp2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..057894506c99a71e2b28e614a10d31ce8ea8cfe5 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/Index.ets @@ -0,0 +1,15 @@ +/* + * 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. + */ +export { add } from './src/main/ets/utils/Calc'; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/build-profile.json5 b/AbilityKit/MetaCompetences/hsp2/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6aa37298cb55a9f4c94c6b5d56fa9fab963090f8 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * 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. + */ +{ + "apiType": "stageMode", + "buildOption": { + "resOptions": { + "copyCodeResource": { + "enable": false + } + }, + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", // CMake脚本路径 + "abiFilters": ["arm64-v8a", "x86_64"] // 编译目标架构 + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/consumer-rules.txt b/AbilityKit/MetaCompetences/hsp2/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/AbilityKit/MetaCompetences/hsp2/hvigorfile.ts b/AbilityKit/MetaCompetences/hsp2/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..3685a087a33c2e63c17d4e98660f489c3f31aa25 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * 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 { hspTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/obfuscation-rules.txt b/AbilityKit/MetaCompetences/hsp2/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/oh-package.json5 b/AbilityKit/MetaCompetences/hsp2/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5a6af822558c186399776ab73c96afb97ca94ed2 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/oh-package.json5 @@ -0,0 +1,26 @@ +/* + * 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. + */ +{ + "name": "hsp2", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "packageType": "InterfaceHar", + "dependencies": { + "libhsp2_01.so": "file:./src/main/cpp/types/libhsp21" + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/cpp/CMakeLists.txt b/AbilityKit/MetaCompetences/hsp2/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..7b202d486fa3a3ddec0b7bfb7edb91fd1f06a6a9 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(MetaCompetences) + +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(hsp2_01 SHARED napi_init1.cpp) + +target_link_libraries(hsp2_01 PUBLIC libace_napi.z.so) + diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/cpp/napi_init1.cpp b/AbilityKit/MetaCompetences/hsp2/src/main/cpp/napi_init1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6f1293b26e4b046d2fed05a9db9200bcbf273802 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/cpp/napi_init1.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ +#include "napi/native_api.h" + +static napi_value Add(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_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, 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 = "hsp2_01", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule1(void) +{ + napi_module_register(&demoModule); +} diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/cpp/types/libhsp21/Index.d.ts b/AbilityKit/MetaCompetences/hsp2/src/main/cpp/types/libhsp21/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13a34842c293a6773ab293fd9e206d13e0a18bb1 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/cpp/types/libhsp21/Index.d.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/cpp/types/libhsp21/oh-package.json5 b/AbilityKit/MetaCompetences/hsp2/src/main/cpp/types/libhsp21/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7de35df9bba3d4a218bdd2590504025e19c151fd --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/cpp/types/libhsp21/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * 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. + */ +{ + "name": "libhsp2_01.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/ets/pages/Index.ets b/AbilityKit/MetaCompetences/hsp2/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8f83477a373839476b4da2220d55f6e3e9b2d0aa --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/ets/pages/Index.ets @@ -0,0 +1,34 @@ +/* + * 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. + */ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/ets/startup/HSP2_Task_01.ets b/AbilityKit/MetaCompetences/hsp2/src/main/ets/startup/HSP2_Task_01.ets new file mode 100644 index 0000000000000000000000000000000000000000..beddb6f4e09280541bceff4bca1434812c0ea0f0 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/ets/startup/HSP2_Task_01.ets @@ -0,0 +1,33 @@ +/* + * 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 { StartupTask, common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +@Sendable +export default class HSP2Task01 extends StartupTask { + constructor() { + super(); + } + + async init(context: common.AbilityStageContext) { + hilog.info(0x0000, 'testTag', 'HSP2_Task_01 init.'); + return 'HSP2_Task_01'; + } + + onDependencyCompleted(dependence: string, result: Object): void { + hilog.info(0x0000, 'testTag', 'HSP2_Task_01 onDependencyCompleted, dependence: %{public}s, result: %{public}s', + dependence, JSON.stringify(result)); + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/ets/startup/StartupConfig.ets b/AbilityKit/MetaCompetences/hsp2/src/main/ets/startup/StartupConfig.ets new file mode 100644 index 0000000000000000000000000000000000000000..f0cdc606e7328cba45df4565b9c383c498c79dc0 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/ets/startup/StartupConfig.ets @@ -0,0 +1,41 @@ +/* + * 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. + */ +// [Start startup_config_0100] +import { StartupConfig, StartupConfigEntry, StartupListener } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +export default class MyStartupConfigEntry extends StartupConfigEntry { + onConfig() { + hilog.info(0x0000, 'testTag', `onConfig`); + let onCompletedCallback = (error: BusinessError) => { + hilog.info(0x0000, 'testTag', `onCompletedCallback`); + if (error) { + hilog.error(0x0000, 'testTag', 'onCompletedCallback: %{public}d, message: %{public}s', error.code, error.message); + } else { + hilog.info(0x0000, 'testTag', `onCompletedCallback: success.`); + } + }; + let startupListener: StartupListener = { + 'onCompleted': onCompletedCallback + }; + let config: StartupConfig = { + 'timeoutMs': 10000, + 'startupListener': startupListener + }; + return config; + } +} +// [End startup_config_0100] \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/ets/utils/Calc.ets b/AbilityKit/MetaCompetences/hsp2/src/main/ets/utils/Calc.ets new file mode 100644 index 0000000000000000000000000000000000000000..a5a468e6949ac73107a40372b2aeeec63227ac6b --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/ets/utils/Calc.ets @@ -0,0 +1,17 @@ +/* + * 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. + */ +export function add(a: number, b: number) { + return a + b; +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/module.json5 b/AbilityKit/MetaCompetences/hsp2/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cd10453087d9707d8ffde729084987f28b591cd8 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/module.json5 @@ -0,0 +1,32 @@ +/* + * 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. + */ +// [Start startup005] +{ + "module": { + "name": "hsp2", + "type": "shared", + // [StartExclude startup005] + "description": "$string:shared_desc", + // [EndExclude startup005] + "appStartup": "$profile:startup_config", // 启动框架的配置文件 + // [StartExclude startup005] + "deviceTypes": [ + ], + "deliveryWithInstall": true, + "pages": "$profile:main_pages", + // [EndExclude startup005] + } +} +// [End startup005] \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/element/float.json b/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/element/string.json b/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..98e1d8a84b3d8539ea33e79fe2ac593a05d23bb4 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "shared_desc", + "value": "description" + } + ] +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/profile/main_pages.json b/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/profile/startup_config.json b/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/profile/startup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..f0f7f5e8c02dbcc343b923d95315069d0346e88f --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/main/resources/base/profile/startup_config.json @@ -0,0 +1,19 @@ +{ + "startupTasks": [ + { + "name": "HSP2_Task_01", + "srcEntry": "./ets/startup/HSP2_Task_01.ets", + "runOnThread": "taskPool", + "waitOnMainThread": false, + "excludeFromAutoStart": true + } + ], + "appPreloadHintStartupTasks": [ + { + "name": "libhsp2_01", + "srcEntry": "libhsp2_01.so", + "runOnThread": "taskPool", + "excludeFromAutoStart": true + } + ] +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/ohosTest/ets/test/Ability.test.ets b/AbilityKit/MetaCompetences/hsp2/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f30942b81554a399e89aa253c7089eca4f8d8d1 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,49 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/ohosTest/ets/test/List.test.ets b/AbilityKit/MetaCompetences/hsp2/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c64e0b06938d246ce044186d4b2d02b500a89e14 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/ohosTest/module.json5 b/AbilityKit/MetaCompetences/hsp2/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..42d0022ad7899795f4eefc03703bac25dc3ef7d0 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/ohosTest/module.json5 @@ -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. + */ +{ + "module": { + "name": "hsp2_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/test/List.test.ets b/AbilityKit/MetaCompetences/hsp2/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hsp2/src/test/LocalUnit.test.ets b/AbilityKit/MetaCompetences/hsp2/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/AbilityKit/MetaCompetences/hsp2/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/hvigor/hvigor-config.json5 b/AbilityKit/MetaCompetences/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3b057578a1bb4d591ee53054e39ab0154fc2e43a --- /dev/null +++ b/AbilityKit/MetaCompetences/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * 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. + */ +{ + "modelVersion": "6.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | 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 */ + // "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */ + }, + "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/AbilityKit/MetaCompetences/hvigorfile.ts b/AbilityKit/MetaCompetences/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae9086af35844176c08f1be3772d081d95d267c6 --- /dev/null +++ b/AbilityKit/MetaCompetences/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * 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 { 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. */ +} \ No newline at end of file diff --git a/AbilityKit/MetaCompetences/img.png b/AbilityKit/MetaCompetences/img.png new file mode 100644 index 0000000000000000000000000000000000000000..9c8c4130707cc5ba17202c8d909c23f41085abf1 Binary files /dev/null and b/AbilityKit/MetaCompetences/img.png differ diff --git a/AbilityKit/MetaCompetences/img_1.png b/AbilityKit/MetaCompetences/img_1.png new file mode 100644 index 0000000000000000000000000000000000000000..e70ef8e4c4576245c4abb81339088e24f4934da6 Binary files /dev/null and b/AbilityKit/MetaCompetences/img_1.png differ diff --git a/AbilityKit/MetaCompetences/oh-package.json5 b/AbilityKit/MetaCompetences/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..837c0ff9f35a6bb9eea849fead7955c19bcdec8d --- /dev/null +++ b/AbilityKit/MetaCompetences/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * 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. + */ +{ + "modelVersion": "6.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.24", + "@ohos/hamock": "1.0.0" + } +} diff --git a/AbilityKit/MetaCompetences/ohosTest.md b/AbilityKit/MetaCompetences/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..cc2b620efda11b19c7a27998ae0a17ed3d951cdb --- /dev/null +++ b/AbilityKit/MetaCompetences/ohosTest.md @@ -0,0 +1,7 @@ +# 基础能力增强测试用例 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|---------------| ------------ |---------------------------|----------------------------|------| -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | Yes | Pass |