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/HiChecker/HiChecker_ArkTS/.gitignore b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/.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/HiChecker/HiChecker_ArkTS/AppScope/app.json5 b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7fa9a61479c24f074fe80f50465a53a3aaabbab8 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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.hicheckerarkts", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/AppScope/resources/base/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..629316b7f8dbf65c26bb47d56b29b6b5c5a81380 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "HiChecker_ArkTS" + } + ] +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/AppScope/resources/base/media/app_icon.png b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/AppScope/resources/base/media/app_icon.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/README_zh.md b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..94fac1507491f13be43de7a83a461e95ab439517 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/README_zh.md @@ -0,0 +1,108 @@ +# 使用HiChecker检测问题(ArkTS) + +### 介绍 + +本示例主要展示了使用HiChecker检测问题(ArkTS)相关的功能,HiChecker可以作为应用开发阶段使用的检测工具,用于检测代码运行过程中部分易忽略的问题,如应用线程出现耗时调用、应用进程中元能力资源泄露等问题。开发者可以通过日志记录或进程crash等形式查看具体问题并进行修改,提升应用的使用体验。 + +### 效果预览 + +| 主页 | +| :----------------------------------------------------------: | +| z | + +使用说明 + +1.先在DevEco Studio Terminal 中执行如下命令: + +``` +PS D:\xxx\xxx> hdc shell +$ hilog|grep -i hichecker +``` + +2.安装hap后运行,shell窗口有如下调用栈信息说明检测成功,成功的数据如下所示: + +``` +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: HiChecker caution with RULE_CAUTION_PRINT_LOG. +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: CautionMsg:trigger:RULE_THREAD_CHECK_SLOW_PROCESS,Trigger: pid = 7782, tid = 7782 +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: StackTrace: +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: Tid:7782, Name:m.example.arkts +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #00 pc 00002bad /system/lib/platformsdk/libhichecker.so(OHOS::HiviewDFX::HiChecker::NotifySlowProcess(std::__h::basic_string, std::__h::allocator> const&)+48)(d13fb7fce5b5364c7a3994c95f66c6c2) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #01 pc 000707cf /system/lib/platformsdk/libimage_napi.z.so(fd73ffee97d631ca6aebf63145d4abf5) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #02 pc 00073b4b /system/lib/platformsdk/libimage_napi.z.so(fd73ffee97d631ca6aebf63145d4abf5) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #03 pc 0002da19 /system/lib/platformsdk/libace_napi.z.so(panda::JSValueRef ArkNativeFunctionCallBack(panda::JsiRuntimeCallInfo*)+1940)(c8fb0be33d21b7b3a3141886132d6ace) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #04 pc 0026507b /system/lib/platformsdk/libark_jsruntime.so(panda::ecmascript::EcmaInterpreter::RunInternal(panda::ecmascript::JSThread*, unsigned char const*, unsigned long long*)+ +5658)(7e10dcf23dabdb59d64870dfb031754e) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #05 pc 002638e9 /system/lib/platformsdk/libark_jsruntime.so(panda::ecmascript::EcmaInterpreter::Execute(panda::ecmascript::EcmaRuntimeCallInfo*)+820)(7e10dcf23dabdb59d64870dfb031754 +e) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #06 pc 00310b87 /system/lib/platformsdk/libark_jsruntime.so(panda::ecmascript::JSFunction::Call(panda::ecmascript::EcmaRuntimeCallInfo*)+394)(7e10dcf23dabdb59d64870dfb031754e) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #07 pc 003f9191 /system/lib/platformsdk/libark_jsruntime.so(panda::FunctionRef::CallForNapi(panda::ecmascript::EcmaVM const*, panda::JSValueRef*, panda::JSValueRef* const*, int)+139 +6)(7e10dcf23dabdb59d64870dfb031754e) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #08 pc 000404db /system/lib/platformsdk/libace_napi.z.so(napi_call_function+154)(c8fb0be33d21b7b3a3141886132d6ace) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #09 pc 0002dda7 /system/lib/platformsdk/libuiabilitykit_native.z.so(OHOS::AbilityRuntime::JsUIAbility::CallObjectMethod(char const*, napi_value__* const*, unsigned int, bool, bool)+ +566)(cd67118764f555a743b52929d2e31614) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #10 pc 0002d6e1 /system/lib/platformsdk/libuiabilitykit_native.z.so(OHOS::AbilityRuntime::JsUIAbility::OnStart(OHOS::AAFwk::Want const&, OHOS::sptr)+552)(c +d67118764f555a743b52929d2e31614) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #11 pc 0005433d /system/lib/platformsdk/libuiabilitykit_native.z.so(OHOS::AbilityRuntime::UIAbilityImpl::Start(OHOS::AAFwk::Want const&, OHOS::sptr)+220)(c +d67118764f555a743b52929d2e31614) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #12 pc 00054bf7 /system/lib/platformsdk/libuiabilitykit_native.z.so(OHOS::AbilityRuntime::UIAbilityImpl::HandleAbilityTransaction(OHOS::AAFwk::Want const&, OHOS::AAFwk::LifeCycleSta +teInfo const&, OHOS::sptr)+742)(cd67118764f555a743b52929d2e31614) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #13 pc 000310e5 /system/lib/platformsdk/libability_thread.z.so(OHOS::AbilityRuntime::UIAbilityThread::HandleAbilityTransaction(OHOS::AAFwk::Want const&, OHOS::AAFwk::LifeCycleStateI +nfo const&, OHOS::sptr)+388)(2fd9baad6ff618a0f34728fb39a7763c) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #14 pc 000345bd /system/lib/platformsdk/libability_thread.z.so(2fd9baad6ff618a0f34728fb39a7763c) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #15 pc 00013157 /system/lib/chipset-pub-sdk/libeventhandler.z.so(OHOS::AppExecFwk::EventHandler::DistributeEvent(std::__h::unique_ptr const&)+1078)(c74cbe7b8d304a356f7640cca71412cb) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #16 pc 0001ec1b /system/lib/chipset-pub-sdk/libeventhandler.z.so(c74cbe7b8d304a356f7640cca71412cb) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #17 pc 0001e39d /system/lib/chipset-pub-sdk/libeventhandler.z.so(c74cbe7b8d304a356f7640cca71412cb) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #18 pc 00020b7f /system/lib/chipset-pub-sdk/libeventhandler.z.so(OHOS::AppExecFwk::EventRunner::Run()+282)(c74cbe7b8d304a356f7640cca71412cb) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #19 pc 00078d21 /system/lib/platformsdk/libappkit_native.z.so(OHOS::AppExecFwk::MainThread::Start()+344)(a7089e05b7494bd92b422053ccbe061e) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #20 pc 0000471b /system/lib/appspawn/appspawn/libappspawn_ace.z.so(9e1434912d947d63b465ec8eb1dd7574) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #21 pc 000098b5 /system/bin/appspawn(d3c9852aafd17fff9f2b355a05fc65ae) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #22 pc 0001004b /system/bin/appspawn(d3c9852aafd17fff9f2b355a05fc65ae) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #23 pc 0000eafb /system/bin/appspawn(d3c9852aafd17fff9f2b355a05fc65ae) +01-05 19:40:22.837 7782 7782 I C02d0b/HICHECKER: #24 pc 0000fcbb /system/lib/chipset-pub-sdk/libbegetutil.z.so(689652343dcb9f4cdb18 + +``` + + + +### 工程目录 + +``` +entry/src/main/ets/ +├─entryability +│ └─---EntryAbility.ets //添加HiChecker的接口 +└─pages + └─---Index.ets //首页 +``` + +### 具体实现 + +- 在“EntryAbility.ets”文件中自己的业务里调用HiChecker的接口,添加检测规则。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +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/HiChecker/HiChecker_ArkTS/ > .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/HiChecker/HiChecker_ArkTS/build-profile.json5 b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5f84e07910e435c25299194dc4abd35d815ff629 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/entry/.gitignore b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/entry/build-profile.json5 b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..eed6635f664fa08b992d84590bf62be7e0bb5381 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * 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": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/hvigorfile.ts b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/entry/obfuscation-rules.txt b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..fdbb5b9852d7dd5f39bddaeb21ab5ee1f3346749 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/entry/oh-package.json5 b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b91b7dca8c48f0030ced6230f22db9e1e92ff309 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,65 @@ +/* + * 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 { window } from '@kit.ArkUI'; +import { image } from '@kit.ImageKit'; +import { UIAbility, Want, AbilityConstant } from '@kit.AbilityKit'; +import { hichecker, hilog } from '@kit.PerformanceAnalysisKit'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // 添加检测规则,规则意义见检测模式API参考 + hichecker.addCheckRule(hichecker.RULE_CAUTION_PRINT_LOG|hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); + let filePath: string = this.context.cacheDir + '/test.JPG'; + const imageSourceApi: image.ImageSource = image.createImageSource(filePath); + const imagePackerApi = image.createImagePacker(); + let packOpts: image.PackingOption = { format:"image/jpeg", quality:98 }; + imagePackerApi.packing(imageSourceApi, packOpts); + // 以上5行通过image子系统触发检测规则 + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreateend'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + 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. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/entry/src/main/ets/pages/Index.ets b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3907b3c0144d6da81dd87c842c73e3f5292d1394 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + Button("HiChecker") + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('60%') + .height('5%') + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/module.json5 b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/element/color.json b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5f11a46a8420b62ae64df7d625235d1fabcaad36 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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": "HiChecker_ArkTS" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/media/background.png b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5f11a46a8420b62ae64df7d625235d1fabcaad36 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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": "HiChecker_ArkTS" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..597ecf95e61d7e30367c22fe2f8638008361b044 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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": "label" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/mock/mock-config.json5 b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/entry/src/mock/mock-config.json5 @@ -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. + */ + +{ +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/hvigor/hvigor-config.json5 b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/hvigorfile.ts b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/oh-package.json5 b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..952ab183532e81c9c50e5de1e64393704e1e48fe --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/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/HiChecker/HiChecker_ArkTS/ohosTest.md b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..5e62889cb54c6a77da37cf4900ba1cf5a0cb07db --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/ohosTest.md @@ -0,0 +1,8 @@ + + +# HiChecker_ArkTS测试用例归档 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------ | ------------ | ------------ | ------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 否 | Pass | +| 主页按钮点击 | 位于主页 | 依次点击按钮 | 输出预期日志 | 否 | Pass | \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/screenshots/Screenshot_20241217173011590.jpeg b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/screenshots/Screenshot_20241217173011590.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..0aabaeb05a3e9d3e3e9754d04591ad9b1fa6c5f3 Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/HiChecker/HiChecker_ArkTS/screenshots/Screenshot_20241217173011590.jpeg differ