diff --git a/OAT.xml b/OAT.xml index 9705a1cbe38d1ac277d21d688189b738b49a37d6..01972bec9289dba44af9358f76fc20b88ac6c994 100644 --- a/OAT.xml +++ b/OAT.xml @@ -372,6 +372,10 @@ Note:If the text contains special characters, please escape them according to th + + + + @@ -416,6 +420,13 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + @@ -475,6 +486,11 @@ Note:If the text contains special characters, please escape them according to th + + + + + @@ -1195,6 +1211,7 @@ Note:If the text contains special characters, please escape them according to th + @@ -1262,6 +1279,31 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1273,6 +1315,30 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + + + + + + + + + + + + @@ -1472,6 +1538,86 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/.gitignore b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/.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/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/AppScope/app.json5 b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ced504e4c4ef24f2b7647a2afaee8ca70e97c54d --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/AppScope/app.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. + */ + +{ + "app": { + "bundleName": "com.samples.hitracechaincpp", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/AppScope/resources/base/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f5050a1717820d671de09c00ed00f829d57637e4 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "HiTraceChain_CPP" + } + ] +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/AppScope/resources/base/media/app_icon.png b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/AppScope/resources/base/media/app_icon.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/README_zh.md b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..e787b3eec8fe7f14df71663dde592ba09fd6b9fa --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/README_zh.md @@ -0,0 +1,62 @@ +# 使用HiTraceChain打点(C/C++) + +### 介绍 + +本示例主要展示了使用HiTraceChain打点(C/C++)相关的功能,HiTraceChain是基于云计算分布式跟踪调用链思想,在端侧业务流程(涉及跨线程、跨进程、跨设备)中的一种轻量级实现。HiTraceChain在业务控制面流程中,生成和传递唯一跟踪标识,在业务流程中输出的各类信息中(包括应用事件、系统时间、日志等)记录该跟踪标识。在调试、问题定位过程中,开发者可以通过该唯一跟踪标识将本次业务流程端到端的各类信息快速关联起来。HiTraceChain为开发者提供业务流程调用链跟踪的维测接口,帮助开发者迅速获取指定业务流程调用链的运行日志,定位跨设备/跨进程/跨线程的故障问题。 + +### 效果预览 + +| 主页 | +| :----------------------------------------------------------: | +| z | + +使用说明 + +1.在主界面点击按钮,切换到"Log"窗口,日志过滤选择"No filters",搜索内容设置为"hitraceTest"。此时窗口仅显示符合条件的日志,打印日志结果为: + +``` +HiTraceBegin name:hitraceTest flags:0x00. +``` + +### 工程目录 + +``` +entry/src/main +├─cpp +│ ├─CMakeLists.txt //导入so链接 +│ └─napi_init.cpp //功能函数,观察者定义 +└─ets + └─pages + └─Index.ets //主页 +``` + +### 具体实现 + +- 在Add函数中,使用OH_HiTrace_BeginChain函数开启一个跟踪链,使用OH_HiTrace_EndChain关闭跟踪。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:RK3568; +2. 本示例已适配API14版本SDK,版本号:5.0.2.58,镜像版本号:OpenHarmony5.0.2.58; +3. 本示例需要使用DevEco Studio(5.0.3.910)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` + diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/build-profile.json5 b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3c9f3e38a1ee941505e3c2de3587fbe638f6c630 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/build-profile.json5 @@ -0,0 +1,52 @@ +/* + * 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", + "compatibleSdkVersion": 14, + "compileSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony" + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/.gitignore b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/build-profile.json5 b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..54378f896f400c96d4c56aea9c74f7646cd2976e --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/build-profile.json5 @@ -0,0 +1,55 @@ +/* + * 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": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": ["arm64-v8a", "x86_64","armeabi-v7a"] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/hvigorfile.ts b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/hvigorfile.ts @@ -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. + */ + +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/obfuscation-rules.txt b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..69c4d6a8a5531548e4886fa766090c5c157a87d9 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# 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 \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/oh-package.json5 b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/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": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..95bc525606ab1189886034dd514e5388c2d6e7e1 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,15 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(CPP2) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so libhitrace_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..03300d92206c85c6b5c78344eaa3a46aa651292a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,72 @@ +/* + * 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" +#include "hitrace/trace.h" + +static napi_value Add(napi_env env, napi_callback_info info) +{ + // 需要开启分布式跟踪的地方 + OH_HiTrace_BeginChain("hitraceTest", HITRACE_FLAG_DEFAULT); + // 需要结束分布式跟踪的地方(此处为示例,开启点和结束点按实际需求放在需要的地方) + OH_HiTrace_EndChain(); + 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", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c14affc63e0dc8a96335ff0c4f6256d392724e2 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * 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/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6abf3b7c20f22c62aaac6a995a25cae672f73f35 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -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. + */ + +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5539bddd7a772710f55da0ddd7b5676305469de --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/ets/pages/Index.ets b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba6e40049e9891a6db8d4f63e455ba21a76e061e --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,44 @@ +/* + * 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 '@ohos.hilog'; +import testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State message: string = 'HiTraceChain C++'; + + build() { + Row() { + Column() { + Button(this.message) + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('60%') + .height('5%') + .onClick(() => { + hilog.info(0x0000, 'testTag', 'Test NAPI 2 + 3 = %{public}d', testNapi.add(2, 3)); + }) + } + .width('100%') + } + .height('100%') + } +} + diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/module.json5 b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/module.json5 @@ -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. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/element/color.json b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/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/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6269c5abd299821599318f9e8c8fd4b4bcea4f1e --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "HiTraceChain_CPP" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/media/background.png b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/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/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6269c5abd299821599318f9e8c8fd4b4bcea4f1e --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "HiTraceChain_CPP" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..83b42c3568a4a11d925d5fd4a935e20a3ba5bb37 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "HiTraceChain_CPP" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/mock/Libentry.mock.ets b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/mock/Libentry.mock.ets new file mode 100644 index 0000000000000000000000000000000000000000..133fac9027ff6bbdcccfe98838fdbb2dc34639ab --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/mock/Libentry.mock.ets @@ -0,0 +1,22 @@ +/* + * 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/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/mock/mock-config.json5 b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2c7d2ba82b796a2850ced0a277d261d7d7355416 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/entry/src/mock/mock-config.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. + */ + +{ + "libentry.so": { + "source": "src/mock/Libentry.mock.ets" + } +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/hvigor/hvigor-config.json5 b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/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": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/hvigorfile.ts b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/hvigorfile.ts @@ -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. + */ + +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/oh-package.json5 b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..952ab183532e81c9c50e5de1e64393704e1e48fe --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/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. + */ + +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.18", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/ohosTest.md b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..0600edfbb4ba1623c14c45b8181a792cfc2aa465 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/ohosTest.md @@ -0,0 +1,8 @@ + + +# HiTraceChain_CPP测试用例归档 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------ | ------------ | ------------ | ------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 否 | Pass | +| 主页按钮点击 | 位于主页 | 依次点击按钮 | 输出预期日志 | 否 | Pass | \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/screenshots/Screenshot_20241217164714258.jpeg b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/screenshots/Screenshot_20241217164714258.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..ad875cc32a5cb0ccf7435218aac94091acc599a7 Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiTraceChain/HiTraceChain_CPP/screenshots/Screenshot_20241217164714258.jpeg differ