diff --git a/OAT.xml b/OAT.xml index 9705a1cbe38d1ac277d21d688189b738b49a37d6..b59f6922ee6b9b623fae87de18e6b94ee05897cb 100644 --- a/OAT.xml +++ b/OAT.xml @@ -103,6 +103,11 @@ Note:If the text contains special characters, please escape them according to th + + + + + @@ -145,6 +150,7 @@ Note:If the text contains special characters, please escape them according to th + @@ -372,6 +378,10 @@ Note:If the text contains special characters, please escape them according to th + + + + @@ -416,6 +426,13 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + @@ -475,6 +492,11 @@ Note:If the text contains special characters, please escape them according to th + + + + + @@ -951,6 +973,9 @@ Note:If the text contains special characters, please escape them according to th + + + @@ -1195,6 +1220,7 @@ Note:If the text contains special characters, please escape them according to th + @@ -1262,6 +1288,31 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1273,6 +1324,30 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + + + + + + + + + + + + @@ -1325,25 +1400,13 @@ Note:If the text contains special characters, please escape them according to th - - - - + - - - - - - - - - - + @@ -1472,6 +1535,118 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/.gitignore b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/AppScope/app.json5 b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f135b7b56173183b04d1c8899666ae77e1b18c22 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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.addressdiseventcpp", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/AppScope/resources/base/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ef6ac489b1ea9aca755a03968291f1c38f8a42b2 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AddressDisEvent_CPP" + } + ] +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/AppScope/resources/base/media/app_icon.png b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/AppScope/resources/base/media/app_icon.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/README_zh.md b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..e586b1aa3ff99fe11310cf1a8bca00d7f11dcabb --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/README_zh.md @@ -0,0 +1,99 @@ +# 订阅踩内存事件(C/C++) + +### 介绍 + +本示例主要展示了使用订阅踩内存事件(C/C++)相关的功能,HiAppEvent提供了事件订阅接口,用于本地获取应用事件。 + +### 效果预览 + +| 主页 | +| :----------------------------------------------------------: | +| z | + +使用说明 + +1.在应用侧主界面,点击"address-sanitizer C++"按钮触发踩内存事件,应用退出后重启应用; +2.在DevEco Studio侧下方导航栏,切换到"Log"窗口,日志过滤选择"No filters",搜索内容设置为"testTag"。此时窗口仅显示符合条件的日志,打印日志结果为: + +``` +HiAppEvent eventInfo.WatcherType=OnTrigger //OnTrigger观察者打印 +HiAppEvent eventInfo.domain=OS +HiAppEvent eventInfo.name=ADDRESS_SANITIZER //ADDRESS_SANITIZER事件 +HiAppEvent eventInfo.eventType=1 +HiAppEvent eventInfo.params.time=1609739933049 +HiAppEvent eventInfo.params.bundle_version=1.0.0 +HiAppEvent eventInfo.params.bundle_name=com.example.cpp +HiAppEvent eventInfo.params.pid=6628 +HiAppEvent eventInfo.params.uid=20010050 +HiAppEvent eventInfo.params.type="stack-buffer-overflow" +HiAppEvent eventInfo.params.external_log=["/data/storage/el2/log/hiappevent/ADDRESS_SANITIZER_1609739933234_6628.log"] +HiAppEvent eventInfo.params.log_over_limit=0 +HiAppEvent eventInfo.WatcherType=OnReceive //OnReceiver观察者打印 +HiAppEvent eventInfo.domain=OS +HiAppEvent eventInfo.name=ADDRESS_SANITIZER //ADDRESS_SANITIZER事件 +HiAppEvent eventInfo.eventType=1 +HiAppEvent eventInfo.params.time=1609739933049 +HiAppEvent eventInfo.params.bundle_version=1.0.0 +HiAppEvent eventInfo.params.bundle_name=com.example.cpp +HiAppEvent eventInfo.params.pid=6628 +HiAppEvent eventInfo.params.uid=20010050 +HiAppEvent eventInfo.params.type="stack-buffer-overflow" +HiAppEvent eventInfo.params.external_log=["/data/storage/el2/log/hiappevent/ADDRESS_SANITIZER_1609739933234_6628.log"] +HiAppEvent eventInfo.params.log_over_limit=0 +``` + +### 工程目录 + +``` +entry/src/main +├─cpp +│ ├─json +│ │ └─json.cpp //自行添加 +│ │ └─json-forwards.h //自行添加 +│ ├─types +│ │ └─libentry +│ │ └─Index.d.ts //定义ArkTS接口 +│ ├─CMakeLists.txt //导入so链接 +│ ├─napi_init.cpp //功能函数,观察者定义 +│ └─jsoncpp.cpp //自行添加 +└─ets + ├─entryability + │ └─EntryAbility.ets //新增接口调用 + └─pages + └─Index.ets //主页 +``` + +### 具体实现 + +1.在entry/src/main/cpp下添加三方库文件jsoncpp.cpp和目录"json","json"目录下添加json.h,和json-forwards.h; +2.编辑"CMakeLists.txt"文件,添加源文件及动态库; +3.编辑"napi_init.cpp"文件,导入依赖的文件,定义onReceive和onTrigger类型观察者相关方法,注册为ArkTS接口,定义一个数组越界的实例模拟地址越界场景; +4.编辑"index.d.ts"文件,定义ArkTS接口; +5.编辑"EntryAbility.ets"文件,在onCreate()函数中新增接口调用; +6.编辑"Index.ets"文件,新增按钮触发踩内存事件。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/build-profile.json5 b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e312bdee1cd355a915d330591875b32cb8a18b41 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/.gitignore b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/build-profile.json5 b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a6a5531c56160aaacf1fb0af4365ebefb11621de --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/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": { + "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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/hvigorfile.ts b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e042e3f963ab27941d3b34f1f027da9933b81df1 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/obfuscation-rules.txt b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..fdbb5b9852d7dd5f39bddaeb21ab5ee1f3346749 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/obfuscation-rules.txt @@ -0,0 +1,22 @@ +# 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/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/oh-package.json5 b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d55b3e8de9d84c6b79c43869a2b2f0948633f7ec --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..fa2f9febd17f978b15af959a2b18032d46f06a46 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,17 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(CPP) + +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) + +# 新增jsoncpp.cpp(解析订阅事件中的json字符串)源文件 +add_library(entry SHARED napi_init.cpp jsoncpp.cpp) +# 新增动态库依赖libhiappevent_ndk.z.so和libhilog_ndk.z.so(日志输出) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so libhiappevent_ndk.z.so) diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b6bdd49164c7238612da19877daad43894f77465 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,184 @@ +/* + * 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 "json/json.h" +#include "hilog/log.h" +#include "hiappevent/hiappevent.h" + +#undef LOG_TAG +#define LOG_TAG "testTag" + +// 定义一变量,用来缓存创建的观察者的指针。 +static HiAppEvent_Watcher *systemEventWatcherR; +static HiAppEvent_Watcher *systemEventWatcherT; + +static void OnReceive(const char *domain, const struct HiAppEvent_AppEventGroup *appEventGroups, uint32_t groupLen) { + for (int i = 0; i < groupLen; ++i) { + for (int j = 0; j < appEventGroups[i].infoLen; ++j) { + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.WatcherType=OnReceive"); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.domain=%{public}s", + appEventGroups[i].appEventInfos[j].domain); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.name=%{public}s", + appEventGroups[i].appEventInfos[j].name); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.eventType=%{public}d", + appEventGroups[i].appEventInfos[j].type); + if (strcmp(appEventGroups[i].appEventInfos[j].domain, DOMAIN_OS) == 0 && + strcmp(appEventGroups[i].appEventInfos[j].name, EVENT_ADDRESS_SANITIZER) == 0) { + Json::Value params; + Json::Reader reader(Json::Features::strictMode()); + Json::FastWriter writer; + if (reader.parse(appEventGroups[i].appEventInfos[j].params, params)) { + auto time = params["time"].asInt64(); + auto bundleVersion = params["bundle_version"].asString(); + auto bundleName = params["bundle_name"].asString(); + auto pid = params["pid"].asInt(); + auto uid = params["uid"].asInt(); + auto type = params["type"].asString(); + auto boolFlag = params["log_over_limit"].asBool(); + std::string logOverLimit = params["log_over_limit"].asBool() ? "true" : "false"; + auto externalLog = writer.write(params["external_log"]); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.time=%{public}lld", time); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_version=%{public}s", + bundleVersion.c_str()); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_name=%{public}s", + bundleName.c_str()); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.pid=%{public}d", pid); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.uid=%{public}d", uid); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.type=%{public}s", type.c_str()); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_log=%{public}s", + externalLog.c_str()); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.log_over_limit=%{public}s", + logOverLimit.c_str()); + } + } + } + } +} + +// 开发者可以自行实现获取已监听到事件的回调函数,其中events指针指向内容仅在该函数内有效。 +static void OnTake(const char *const *events, uint32_t eventLen) { + Json::Reader reader(Json::Features::strictMode()); + Json::FastWriter writer; + for (int i = 0; i < eventLen; ++i) { + Json::Value eventInfo; + if (reader.parse(events[i], eventInfo)) { + auto domain = eventInfo["domain_"].asString(); + auto name = eventInfo["name_"].asString(); + auto type = eventInfo["type_"].asInt(); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.WatcherType=OnTrigger"); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.domain=%{public}s", domain.c_str()); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.name=%{public}s", name.c_str()); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.eventType=%{public}d", type); + if (domain == DOMAIN_OS && name == EVENT_ADDRESS_SANITIZER) { + auto time = eventInfo["time"].asInt64(); + auto bundleVersion = eventInfo["bundle_version"].asString(); + auto bundleName = eventInfo["bundle_name"].asString(); + auto pid = eventInfo["pid"].asInt(); + auto uid = eventInfo["uid"].asInt(); + auto asanType = eventInfo["type"].asString(); + auto externalLog = writer.write(eventInfo["external_log"]); + std::string logOverLimit = eventInfo["log_over_limit"].asBool() ? "true" : "false"; + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.time=%{public}lld", time); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_version=%{public}s", + bundleVersion.c_str()); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_name=%{public}s", bundleName.c_str()); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.pid=%{public}d", pid); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.uid=%{public}d", uid); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.crash_type=%{public}s", asanType.c_str()); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_log=%{public}s", + externalLog.c_str()); + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.log_over_limit=%{public}s", + logOverLimit.c_str()); + } + } + } +} + +// 开发者可以自行实现订阅回调函数,以便对获取到的事件打点数据进行自定义处理。 +static void OnTrigger(int row, int size) { + // 接收回调后,获取指定数量的已接收事件。 + OH_HiAppEvent_TakeWatcherData(systemEventWatcherT, row, OnTake); +} + +static napi_value RegisterWatcher(napi_env env, napi_callback_info info) { + // 开发者自定义观察者名称,系统根据不同的名称来识别不同的观察者。 + systemEventWatcherT = OH_HiAppEvent_CreateWatcher("onTriggerWatcher"); + // 设置订阅的事件为EVENT_ADDRESS_SANITIZER。 + const char *namesT[] = {EVENT_ADDRESS_SANITIZER}; + // 开发者订阅感兴趣的事件,此处订阅了系统事件。 + OH_HiAppEvent_SetAppEventFilter(systemEventWatcherT, DOMAIN_OS, 0, namesT, 1); + // 开发者设置已实现的回调函数,需OH_HiAppEvent_SetTriggerCondition设置的条件满足方可触发。 + OH_HiAppEvent_SetWatcherOnTrigger(systemEventWatcherT, OnTrigger); + // 开发者可以设置订阅触发回调的条件,此处是设置新增事件打点数量为1个时,触发onTrigger回调。 + OH_HiAppEvent_SetTriggerCondition(systemEventWatcherT, 1, 0, 0); + // 使观察者开始监听订阅的事件。 + OH_HiAppEvent_AddWatcher(systemEventWatcherT); + + // 开发者自定义观察者名称,系统根据不同的名称来识别不同的观察者。 + systemEventWatcherR = OH_HiAppEvent_CreateWatcher("onReceiverWatcher"); + // 设置订阅的事件为EVENT_ADDRESS_SANITIZER。 + const char *namesR[] = {EVENT_ADDRESS_SANITIZER}; + // 开发者订阅感兴趣的事件,此处订阅了系统事件。 + OH_HiAppEvent_SetAppEventFilter(systemEventWatcherR, DOMAIN_OS, 0, namesR, 1); + // 开发者设置已实现的回调函数,观察者接收到事件后回立即触发OnReceive回调。 + OH_HiAppEvent_SetWatcherOnReceive(systemEventWatcherR, OnReceive); + // 使观察者开始监听订阅的事件。 + OH_HiAppEvent_AddWatcher(systemEventWatcherR); + return {}; +} + +static napi_value Test(napi_env env, napi_callback_info info) { + int a[10]; + // 构造数组越界写入 + a[10] = 1; + return {}; +} + +static napi_value RemoveWatcher(napi_env env, napi_callback_info info) { + // 使观察者停止监听事件 + OH_HiAppEvent_RemoveWatcher(systemEventWatcherT); + OH_HiAppEvent_RemoveWatcher(systemEventWatcherR); + return {}; +} + +static napi_value DestroyWatcher(napi_env env, napi_callback_info info) { + // 销毁创建的观察者,并置appEventWatcher为nullptr。 + OH_HiAppEvent_DestroyWatcher(systemEventWatcherT); + OH_HiAppEvent_DestroyWatcher(systemEventWatcherR); + systemEventWatcherT = nullptr; + systemEventWatcherR = nullptr; + return {}; +} + +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"registerWatcher", nullptr, RegisterWatcher, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"test", nullptr, Test, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} + +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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..272eafcf3fdae576ed57e1b4842d1f76bd96dd0c --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/cpp/types/libentry/Index.d.ts @@ -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 const registerWatcher: () => void; +export const test: () => void; diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..88838fa0b2042f057b1d730054d5698b61c7fb58 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..82229ab7246c5a46cf043196b350e1f492cafbae --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/ets/entryability/EntryAbility.ets @@ -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. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import testNapi from 'libentry.so' + + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + testNapi.registerWatcher(); + } + + 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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..29feaca7669174be5c2b0e2366529ee94ab7e726 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/ets/pages/Index.ets b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..c820a9c8a0a0db248632d8941c294f66b86a656b --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + Button("address-sanitizer C++") + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + .onClick(() => { + testNapi.test(); + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/module.json5 b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9f7f873fbc51484895e18fcfd60b2498521aecb0 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/element/color.json b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2154284a61ccda6c4b8e90b72e194281638cf264 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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": "AddressDisEvent_CPP" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/media/background.png b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2154284a61ccda6c4b8e90b72e194281638cf264 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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": "AddressDisEvent_CPP" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..af687ca6cfbbb81b1565814c73d46e2f98f66dc7 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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": "AddressDisEvent_CPP" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/mock/Libentry.mock.ets b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/mock/Libentry.mock.ets new file mode 100644 index 0000000000000000000000000000000000000000..37c4693badee0bced9f50f020403147ada0e8d44 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/mock/mock-config.json5 b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..25f4db9dcf89e656abe1a6776fe21cd00fc94dac --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/hvigor/hvigor-config.json5 b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a2c44fdf8f9ac103168672568ff000ac395a2edc --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/hvigorfile.ts b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..79d8761856e2996edc0649eca63b96b2c883b28a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/oh-package.json5 b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b7f346f7ddb2fc98ac428c55207a63ff89ea1c70 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_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/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/ohosTest.md b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..77f3056d6983ece216ab032d40663719a952396c --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/ohosTest.md @@ -0,0 +1,6 @@ +# AddressDisEvent_CPP测试用例归档 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------ | ------------ | ------------ | ------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 否 | Pass | +| 主页按钮点击 | 位于主页 | 依次点击按钮 | 输出预期日志 | 否 | Pass | \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/screenshots/Screenshot_20241217152733739.jpeg b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/screenshots/Screenshot_20241217152733739.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..cb167bacf1528dd8154ec1447eca0b14bd1cf602 Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiAppEvent/EventSub/SystemEvents/AddressDisEvent/AddressDisEvent_CPP/screenshots/Screenshot_20241217152733739.jpeg differ